Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery select element with multiple attributes

Ok..i'm having a brainfart right now with jquery's selector process (yes, it's quite confusing to start).

I have 2 input elements on the page, of which I want to remove one.

here are my inputs:

<input value="[email protected]" name="Email" type="hidden">

<input value="[email protected]" id="Email" name="Email" type="text">

I have a blur method on #Email that will remove the hidden Email field. Unfortunately, I'm having a hard time targeting it to remove it.

Can someone help relieve my brainfart? I tried using :not, multiple attributes, etc. The hidden field is server generated and I can't stop it from being sent back.

Thoughts?

like image 608
Loony2nz Avatar asked Feb 18 '10 20:02

Loony2nz


People also ask

How to select multiple attributes in jQuery?

Multiple Attribute [attr="value"][attrn="valuen"] Examples Selectors << Top. Selects all elements that match all of the specified attribute and value filters.

How get multiple data attribute values in jQuery?

that's because when you call the data method on the jQuery object, it returns the data for the first element in the nodeList. To get the data for all the div's you have to loop through the elements with the $. each method or use a mapping to retrieve the attributes in a list. Show activity on this post.

Can we use multiple selectors in jQuery?

You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order.

How use contains in jQuery?

The :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).


2 Answers

$('input[type=hidden][name=Email]').remove();

should do. You can learn more about jQuery selectors here.

like image 96
BalusC Avatar answered Nov 15 '22 13:11

BalusC


$('input[name=Email][type=hidden]').remove()
like image 29
Keith Rousseau Avatar answered Nov 15 '22 13:11

Keith Rousseau