user3739958 user3739958 - 28 days ago 10
Javascript Question

Jquery this.find() not picking anything up?

I hope you can help. I am trying to set part of a column to a text area.

$('#myListview .list-item').click(function() {
getId('textarea-Status').value(this.innerHTML);
}


I printed out 'this' which shows all of my HTML however I only want to show a specific part:-

Within the HTML that I have printed out to a text area I want to be able to print the row ID called 'data-roid'.

<div class = "ui-btn-text listview-row" **data-rowid="123456789"**>


So basically my new text are value wuld = '123456789'

getId('textarea-sysID').value($(this).find('data-rowid').text()));
sysID = $(this.data-rowid);
alert(sysID.innerHTML);
getId('textarea-sysID').value(sysID);
getId('textarea-sysID').value = JSON.stringify(sysID);


Would really appreciate any help.

Thanks

Answer

Get element by has attribute selector and attribute value by using data() method.

$(this).find('[data-rowid]').data('rowid')
Comments