I want to create a jquery plugin and use that for some HTML elements in my page. This is my HTML code :
<select class="test">
<option>
111
</option>
<option>
222
</option>
<option>
333
</option>
</select>
<select class="test">
<option>
444
</option>
<option>
555
</option>
</select>
I want to use my plugin for select elements.
This is my plugin sample :
(function ( $ ) {
$.fn.testplug = function() {
var res = "";
this.children("option").each(function(){
res+=$(this).text()+"#";
});
alert(res);
};
}( jQuery ));
And for using it :
$(".test").testplug();
Now i aspect to have two res values,one of them should be 111#222#333# and another should be 444#555#, but i have one result and it's 111#222#333#444#555#.
What should i do for getting my desired result?
Link to jsfiddle