Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
145
rated 0 times [  149] [ 4]  / answers: 1 / hits: 21456  / 11 Years ago, tue, december 10, 2013, 12:00:00

I have a situation in which i want to convert a <select> tag into a <input type=text> and <input type=text> into <select> bu using some condition.
So how can i know that this element a type text or type select using id attribute.


More From » jquery

 Answers
83

By using



$(#inputID).attr(type);


If you alert above you will get the type of input element, then you can apply checks accordingly.



Ref here : http://api.jquery.com/attr/



UPDATE



check using



if(!$(#inputID).is(select)) {
// the input field is not a select
}


got from a link while searching not tested though.


[#73820] Monday, December 9, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
Sat, Sep 25, 21, 00:00, 3 Years ago
Sun, Jan 31, 21, 00:00, 3 Years ago
Wed, Dec 2, 20, 00:00, 4 Years ago
Fri, Oct 23, 20, 00:00, 4 Years ago
;