I need to add elements to the class and remove it, if there is already a class if i removeclass "I remove the line, then" addClass "works properly.
$ (". Tagy li"). Click (function () {$ (this). Find (": input"). Click (); $ (this) .toggleClass ('selection');});
Can you help me, what did I do? Thanks, Michael
If I remove the line with the input click, the toggle class works correctly, but I need to keep it. Test:
Haha! I think use the case of event.stopPropagation ()
:
$ (". Tagy li") (function () {$ (this). Search (": Input"). Focus (); // Maybe you want to focus on input $ (this). Toggle class ('selection');}); $ ("Taggi li"). (': Input'). ('Click on focus', function (e) {e.stopPropagation (); // stop event bubble up});
Because your input element Lee
is causing any problem to children and parents due to bubbles, this is causing the problem. You can event.stopPropagation ()
.
$ (" taggi li "). Click (function () {$ (this ) .Find (": Input"). Focus (); $ (this) .toggleClass ('Lselected');}); $ ("Taggi li"). (': Input'). ('Click on focus', function (e) {e.stopPropagation (); // close event bubble}};
. Selected (background: red;}
& lt; script src = "https: //ajax.googleapis .com / ajax / libs / jquery / 2.1.1 / jquery.min.js "& gt; aasdfasfd & Lt; Input Type = 'Text' / & gt; & lt; / li & gt;
No comments:
Post a Comment