Reputation: 652
I am using this to remove a specific input
button I don't want to be shown.
$('input[name="FRANCHISE_SOUND0001"]').remove();
But I'd like to remove all of these inputs.
There is 100's of them and each have a unique identifier depending on the logged in user.
input[name="FRANCHISE_SOUND_FILE0001"]
input[name="FRANCHISE_SOUND_FILE0002"]
input[name="FRANCHISE_SOUND_FILE0003"]
input[name="FRANCHISE_SOUND_FILE0004"]
The only constant is input[name="FRANCHISE_SOUND_FILE"]
where the 4 last digits following FILE is unique to the user.
How can I remove them all at once?
Can this be done in same manner as above
$('#NOTES0001').remove();
$('#NOTES0002').remove();
$('#NOTES0341').remove();
Upvotes: 1
Views: 1083
Reputation: 33943
Use this CSS selector comparison operator ^=
which means "begining with" like so:
$('input[name^="FRANCHISE_SOUND_FILE"]').remove();
For id
:
$('[id^="NOTES"]').remove();
For class
:
$('[class^="Some_className_first_characters"]').remove();
It works the same for any HTML attribute.
W3C easy tutorial here.
You may be interested by "contains" *=
operator too! Read here.
;)
Upvotes: 1