I’m learning jQuery and had a question about a method call on an HTML element. In this case it’s a <div> tag.
The jQuery call goes like this:
<script type="text/javascript">
$(function(){
$('.someClass').myMethod({
value1: 'sometext',
value2: 'someothertext'
});
});
</script>
The <div> tag has a CSS class of ‘someClass’, as you can see below:
<div class="someClass" style="display: none;">
<div id="my-content">
<img id="enter" alt="Logo" src="images/logo.png">
</div>
</div>
My question is, what’s happening with that method call in jQuery? Is it looping over all elements contained within the <div class='someClass'/> and calling myMethod on all of them?
It completely depends on the plugin implementation.
$('.someClass')will select all the elements with calss.someClassnow its the plugin which will use this set and apply its logic on the set of matched elements or just a single element.