如何使用javascript在文本框中输入文本时按钮图像按钮的颜色
我有一个文本框和两个图像按钮,最初图像按钮为蓝色,当文本输入文本框时按钮应更改为红色(其他图像按钮),很快回复,感谢提前
i have a textbox and two image buttons in form,initially the image button is in blue color when the text is entered in the textbox the button should change to redcolor(other image button),reply soon,thanks on advance
您好,
请找到您的答案。我使用过jQuery ---
Please find your answer. I have used jQuery---
< input type =" text" id =" txt" />
< input type =" button"名称= QUOT;试验" ID = QUOT; BTN2" value ="按钮2" style =" background-color:blue" />
< script type =" text / javascript">
jQuery(document).ready(function(){
jQuery(" #txt")。keyup(function(){
if(jQuery(this).val()。length> 0)
jQuery(" #btn2")。css(" background -color"," red");&
else
  ; jQuery(" #btn2")。css(" background-color"," blue" ;);
});
});
< / script>
<input type="text" id="txt"/>
<input type="button" name="test" id="btn2" value="Button 2" style="background-color:blue"/>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#txt").keyup(function() {
if (jQuery(this).val().length > 0)
jQuery("#btn2").css("background-color", "red");
else
jQuery("#btn2").css("background-color", "blue");
});
});
</script>