javascript - How to change 'hover' function to 'on' function? -
I have to use the 'on' function instead of 'hover', this is the old code:
$ ('.field'). Item_id = $ (this) .attr ('id'); item = $ (this) .parent ('td'); new_name = (old_value = = 'Not translated')? '': Old_man; $ (this) .empty (); var field = "& lt; div id = 'save_button' class = 'btn btn-primary' style = 'float: right' href = '#' & Gt; Save & lt; / div & gt; & lt; form & gt; "+" div style = 'overflow: hidden; padding -right: .5em;' & gt; "+ "& Lt; input id = 'new_value' type = 'textarea' name = 'term' style = 'width: 100%;' value = '" + new_value + "' / / gt; & lt; / div & gt; & Lt; / form & gt; "; $ (this) .html (field);}, function () {$ (this) .empty (); $ (this) .html (old_value);}); And this is the new code:
$ ('.field'). ('Hover', function (event) {old_value = $ (this) .text (); item_id = $ (this) .attr ('id'); item = $ (this) .Parent ('td'); New_value = (old_value == 'no translation')? '': Old_value; $ (This) .empty (); var field = "div id = 'save_button' class = 'btn btn-primary' style = ' Float: Right 'href =' # '& gt; Save & lt; / div & gt; & lt; + "& lt; div style =' Overflow: hidden; padding-right: .5em; '& gt;" Style = 'width: 100%;' value = '"+ new_value +"' /> gt; & lt; / div & gt; Gt; & lt; / form & gt; "; $ (this) .html (field);}, function (event) {$ (this) .empty (); $ (y H) .html (old_valued);}); The old code works well, but the new one does not work (only the moutout function works). Please, tell me, where have I made a mistake? Thank you.
The easiest thing could possibly be mousecenter and mouseleave Here is jQuery: function (FunOver, Fnot) {back to it}, separately (which is the same as hover ). Musician (For Over) Mouseleave (fnOut || fnOver); } You can pass event handlers to the map of the event names nearby:
$ ('.field'). ({Mousecenter: function} {// passed to hover the first function}, mouseleave: function (event) {// passed to hover another function}}); But there is nothing wrong with . Then () , so that you can stick with it.
Comments
Post a Comment