I'm creating a bunch of form elements like textbox,textarea,checkbox and dropdownlists
dynamically and i want to select only textboxes
whose id ends with some value. How can we accomplish this in jQuery
.
PS I know how to select an element whose id ends with by using $( "[attribute$='value']" )
selector. But here i have apply some kind of filter to select only text boxes.Below is the final html output rendered after the element creation. Now how can i select only textbox
with id txtFirstnamefeedback1
.
<input type="text" id="txtFirstnamefeedback1">
<input type="text" id="txtLastnamefeedback1">
<input type="text" id="txtSurnamefeedback1">
<p id="pfavblogliteraltextfeedback1">Select your interested blog </p>
<input type="checkbox" id="chk1favBlogfeedback1" value="Bike">ASP.NET Web Forms</ br>
<input type="checkbox" name="chk2favBlogfeedback1" value="Car">ASP.NET MVC
Add type in selector, :text will filter out only the textboxes ie all html elemnent where input
type is text
$(":text[attribute$='value']")
Your selector would be like
$(":text[id$='feedback1']")
这将选择文本框以及文本区域
$('input[type=text], textarea')
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.