How to kill the loop inside each?
i mean here is my code when QUERY is has 100 results and somehow(i will be so happy if you would explain me why) the alert pops 100 times after clicking ONLY one one result
(clicking on one result needs to pop the alert 1 time)
var tit_id = '#tit_' + this.SN;
function paintDATA(QUERY) {
var incld = '<div>';
$.each(QUERY, function () {
if (this.wCount != 0) {
$(tit_id).click(function () {
alert('RRRRRRRRRRRRRRR')
});
<div id="tit_' + shipment + '">
For each element returned by the query, you’re attaching the same handler on the same element:
Did you want to attach the click handler on each item returned instead?
EDIT
So if you want to alert, then exit from the each loop, you can, like Jasper says, return false from the each callback: