html & [removed] How to store data referring to html elements

前端 未结 8 1160
悲哀的现实
悲哀的现实 2020-12-31 15:29

I\'m working on a web application that uses ajax to communicate to the server. My specific situation is the following:

I have a list of users lined out in the html p

8条回答
  •  臣服心动
    2020-12-31 15:51

    There is jQuery's data function

    $('li').data('userid',uid); // sets the value of userid
    uid = $('li').data('userid'); // retrieves the value of userid
    

    official documentation: http://docs.jquery.com/Data

提交回复
热议问题