Michael
Michael

Reputation: 8729

Adding Jquery to ASP.Net created Element

I have a gridview that puts a drop down list in every cell of a certain column.

I want all the dropdownlists to implement a Jquery select class. The normal way to do this is as follows

<script type="text/javascript">
$(function () {
    $("#language").selectbox();
});
</script>

Now the problem is there will be multiple with different ID's so I cant set it this way.. Is there any way to set all drop down lists as per their cssclass or a way to do it inline? (ie i can add attributes to the dropdownlist through C#)

Upvotes: 1

Views: 53

Answers (1)

Musa
Musa

Reputation: 97672

To select multiple elements by their ids just specify them as a comma separated list as a selector

$("#id1,#id2,#id3")

If all the elements you want to select has a class use a dot . before the class in the selector

$(".yourclass")

http://api.jquery.com/category/selectors/

Upvotes: 1

Related Questions