javascript - Jquery .data() method not working when getting html attributes -


For some reason, jquery .data () method is only set when using data jquery. Attempt to retrieve data attributes, set in html results in the result of zero results, or in return for the undefined. Here's my javascript and html.

  var ico = "& span class = 'deleteTag'> "; Var x = "& lt; span class = 'usertag' Data-id = '' + ui.item.userid +" '& gt; "+ Ui.item.label +" "+ + ico +" & lt; / Span & gt; "; $ (" # "+ Id +" .userEditor "). Prepaid (x); $ (" # "+ Id +" .userEditor .deleteTag "). Bind (" click ", function Attribute ($ (this). Parent () Attr ("data-id") Alert ($ (this ()) "Data" ("ID"); Warning ($ ("# testdivv"). ("Yola"); $ (this) .Parent (.) Data ("yolo", "swag"); Warning ($ (this) .Parent (.) Data ("yolo")); // $ ( This) .Parent (). Remove ();});  
  
& lt; / div & gt; ; & Lt; div class = "user suggestions" & gt; & lt; / div & gt; & lt; input name = "idlist" class = "hiddenPut" type = "hiding" /> & Gt; & lt; / form & gt;

This is a job.

It works for me in Chrome.

  $ (document) .ready (function () {var id = "editor1"; var ui = {item: {userid: "user1", label: "some labels"}}; Var ico = "& lt; a href = '#' class = 'delete tag' & gt; edit tag & lt; / a & gt;"; var x = "& lt; span class = 'usertag' data-id = '"+ Ui.item $ (" # "+ id +" .userEditor "). Interval (x); $ (" # "+ id +" .userEditor .deleteTag "). Bind (" click ", function () {$ ("# Answer") .HTML ($ (this) .Parent (.) Data ("id"));});});  

Comments

Popular posts from this blog

sip - Call SipJs to Asterisk 12 -

Python Equivalent for matlab cart2pol and pol2cart -

Docker - Tomcat and PostgreSQL containers in same host - No Route to host -