我有兩種輸入形式。我希望當用戶關注第一個輸入表單時顯示第二個輸入表單。我在輸入標籤中使用了一個簡單的javascript「onfocus」。當它改變另一個輸入表單的樣式時,它工作得很好。然而這留下了不必要的差距。我嘗試過,所以整個div小組都出現在焦點上,但它沒有效果。input onfocus not changing div style
我想讓整個「form-group」div在用戶關注第一個輸入表單時出現,但由於某種原因,這根本不起作用。
HTML
<div class="form-group<?php if(form_error('con_password') != ''){ echo " has-error"; } ?>">
<div class="col-md-10">
<input type="password" name="con_password" class="form-control input-lg" placeholder="Password Confirmation" onfocus="occupation.style.display='block'">
<span class="help-block"><?php echo form_error('con_password'); ?></span>
</div>
</div>
<div class="form-group<?php if(form_error('occupation') != ''){ echo " has-error"; } ?>" id="occupation">
<div class="col-md-10">
<input type="text" name="occupation" class="form-control input-lg" value="<?php echo set_value('occupation'); ?>" placeholder="Occupation" onfocus="hearus.style.display='block'">
<span class="help-block"><?php echo form_error('occupation'); ?></span>
</div>
</div>
CSS
#occupation{
display: none;
}
你可以設置一個[JSFiddle](http://jsfiddle.net/)嗎? –
它適用於我。 (儘管沒有所有的PHP)。 – putvande
它在JSFiddle上運行良好,這就是爲什麼我很困惑。 http://jsfiddle.net/ducg5/ – Jonnerz