user3424451
user3424451

Reputation: 89

Dynamically Adding Data Roles (Collapsible data role)

I have a table with a table data-role that i would like to add a collapsible data role to. However i would have to add this dynamically through JQuery Mobile code.

 $('#tabledataroleid').data('role','collapsible-set');
 $('#tabledataroleid').data('role','collapsible');

Is there something off with my code? ^

Upvotes: 1

Views: 67

Answers (1)

Josh
Josh

Reputation: 251

You should be using the jQuery .attr() method to add attributes to an element. Try this:

$('#tabledataroleid').attr('role','collapsible-set');
$('#tabledataroleid').attr('role','collapsible');

Upvotes: 1

Related Questions