Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript或jQuery通过类选择元素_Javascript_Jquery - Fatal编程技术网

使用javascript或jQuery通过类选择元素

使用javascript或jQuery通过类选择元素,javascript,jquery,Javascript,Jquery,我有以下html snippit <input name='first' class="foo" /> <input name='second' class="foo bar" /> <input name='third' class="foo" /> 似乎工作正常,请确保在dom上运行就绪 $(function() { $('.bar').val('selected'); }); 这很有效。。。 $(function() { $('.ba

我有以下html snippit

<input name='first' class="foo" />
<input name='second' class="foo bar" />
<input name='third' class="foo" />

似乎工作正常,请确保在dom上运行就绪

$(function() {
    $('.bar').val('selected');
});
这很有效。。。
$(function() {
    $('.bar').val('selected');
});