jQuery(document).ready(function($) {
$('input[type="text"]').live('focus', function() {
if (this.value == 'someValue') {
this.select();
}
});
});
与.delegate()和.on()相同的结果。
我错过了什么?
感谢任何帮助,谢谢!
答案 0 :(得分:2)
使用.on
为我工作正常。也许您希望它在您单击时选择文本?
$("form").on("click", ":text", function(){
if ( $(this).val() === "someValue" ) {
$(this).select();
}
});
答案 1 :(得分:2)
答案 2 :(得分:0)
DEMO:http://jsfiddle.net/hjgZ3/
从$
function($)
<input type="text" value="someValue" />
$(function(){
$('input[type="text"]').live('focus', function() {
if (this.value == 'someValue') {
alert('hi');
//this.select();
}
});
})