user1546650
user1546650

Reputation: 59

JQuery mobile getting info from data tag

            echo <<<_END
           <pre>
           <a href="#home" data-rel="dialog" data-num="$row[1]" data-id="myid">$row[1]</a>
           </pre>
           _END;

            <script>
    var b = $('a#myid').data('num');
    document.write(b);
    </script>

How do I get data-num info from the tag when the link has been followed?

Upvotes: 0

Views: 159

Answers (1)

Engineer
Engineer

Reputation: 48793

Add '=' between attribute's name and value:

 <a href="#home" data-rel="dialog" data-num="$row[1]">$row[1]</a>
 //                                        ^---here it is

and then retrieve it like this:

$('a').data('num')

Upvotes: 2

Related Questions