I have many divs with class .modal-dialog
and a data field like data-modal='student'
and set it to display:none
I select and store it on variable like
modal_dialog= $('.modal-dialog')
Now I need to show modal with a particular data-modal attribute.
I tried
modal_dialog.hasData('student').show();
modal_dialog.data('student').show();
but didn't work. Any idea how to get this work?
答案 0 :(得分:1)
Use .filter
with the attribute selector:
foo.filter('[data-bar="baz"]')
答案 1 :(得分:0)
If the data field is an actual attribute, you can do
$('.modal-dialog[data-modal]').show();
答案 2 :(得分:0)
If you need to look for the actual value in data-modal
,
$('.modal-dialog[data-modal="student"]').show();