I am using data_attribute in the page and i have followings element with data attribute.
No. 1.<div class="row hidden" data-party-registration-source-type-id="1">
2.<div class="row hidden" data-party-registration-source-type-id="2,3">
3.<div class="row hidden" data-party-registration-source-type-id="3">
4.<div class="row hidden" data-party-registration-source-type-id="4,5">
5.<div class="row hidden" data-party-registration-source-type-id="11">
6.<div class="row hidden" data-party-registration-source-type-id="10">
Now i want to show all div that have data-party-registration-source-type-id =3 It will show No.2 and 3. I am using this to search
var partyRegistrationSourceId = $partyRegistrationSourceTypes.val();
$('[data-party-registration-source-type-id*=' + partyRegistrationSourceId + ']').removeClass("hidden");
It is working fine, now the problem is, when i want to search with id "1", it brings number 1,5,6. Every id that contains 1, it bring it. I only want with the id 1. How i can do this? if i use this:
$('[data-party-registration-source-type-id=' + partyRegistrationSourceId + ']').removeClass("hidden");
Then it will work in this case but not working in above case. How i can search all id that contains exact id?
you could try adding kind of separators for each key:
<div class="row hidden" data-party-registration-source-type-id="{1}">
<div class="row hidden" data-party-registration-source-type-id="{2},{3}">
<div class="row hidden" data-party-registration-source-type-id="{3}">
var partyRegistrationSourceId = $partyRegistrationSourceTypes.val();
$("[data-party-registration-source-type-id*='{" + partyRegistrationSourceId + "}']").removeClass("hidden");
Let me know if suits your problem or is not what you need
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.