I'm using this script http://mondaybynoon.com/2009/02/23/creating-custom-form-elements-using-jquery-selects/ to create custom css select boxes in my page. Javascript code that is used to apply the css styles on selectboxes, uses their id as a parameter:
$(document).ready(function() {
$('#cont').selectbox({debug: true});
});开发者_如何学C
<select id="cont" name="cont" tabindex="1">
<option value="1">aaa</option>
<option value="2">bbb</option>
<option value="3">ccc</option>
</select>
Can I somehow use just the "name" attribute of select boxes and not the "id"??? Is this possible?
you can use the attribute selector to selct via name
e.g.
$('select[name="cont"]').selectbox({debug: true});
Sure, to base your selector off of the name-attribute, simply do the following:
$("[name='nameHere']");
This is how you do it
$("[name='cont']");
Combining it with an element selector will make it faster:
$("select[name='cont']");
Though In the example you give, I can't imagine why. The following will be so much faster:
$("#cont");
精彩评论