I have several id that has the following name test1, test2, test3, test4 and I have the following jQuery:
jQuery(document).ready(function() {
jQuery('#test').jcarousel({
//something
});
});
I have the following code as well:
jQuery.get(
'allmovieloader.php',
{
first: carousel.first,
last: carousel.last
id: myelementid
},
function(xml) {
mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
},
'xml'
);
So when I call get I want to pass in the id as well, as test1, test2, test3
How should I change this jQuery code so that it works for test1, test2, test3
It’d be far easier to assign a class-name to the various elements, and then use the class as the selector (
$('.className').jcarousel({ // something })), but if you want to useids as the selector you’ve got a couple of choices:First:
Secondly:
Based on your comment to @Bjorn:
You could still use the class-name as the selector:
To get the element name (I’m assuming you mean tag-name?) you can use:
References:
^=) selector.