Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created textbox dynamically in tabpanel and set specific id to that textbox but while I trying to get that textbox its id get change according to setting for account and tab number.

Texbox id is made as:

HTML
"tcProperty_tab" + 0 + "_StreetName"
tcProperty_tab - static prefix to all controls
0              - tab number set according to tab
streetName     - static suffix


How can get that textbox using jquery by matching starting and ending pattern>???
Posted
Updated 21-Sep-15 3:23am
v2

1 solution

Use attribute selectors...
https://api.jquery.com/category/selectors/attribute-selectors/[^]
|= used for prefix and $= for suffix...combine them and use them on the 'id' attribute...
 
Share this answer
 
Comments
Member 11774876 21-Sep-15 9:21am    
I have used as $('textarea[id^="tcProperty_tab"]').filter('[id$="_Latitude"]').val($("#lbllatitude").text());
But it's not works.

Also have used
if ($('textarea[id^="tcProperty_tab"][id$=_Latitude]').lengt) {

$('textarea[id^="tcProperty_tab"]').filter('[id$="_Latitude"]').val($("#lbllatitude").text());
$('textarea[id^="tcProperty_tab"]').filter('[id$="_Longitude"]').val($("#lbllongitude").text());
}

Still not works..!
Kornfeld Eliyahu Peter 21-Sep-15 9:32am    
You should have something similar to this:
$('[id|="tcProperty_tab"][id$="streetName"]')
Member 11774876 21-Sep-15 9:43am    
Not working..
var txtstreetname = $('[id|="tcProperty_tab"][id$="streetName"]');

alert(txtlatitude.length);
gives = 0
Kornfeld Eliyahu Peter 21-Sep-15 9:50am    
You (and me) have two errors...
You: case sensitivity... streetName vs StreetName - JavaScript (and therefore jquery) is case sensitive...
Me: I used |= instead of ^=...

See here: http://jsfiddle.net/mLb0t6k9/
Member 11774876 21-Sep-15 9:56am    
Ha ha that's the problem..
Thanks Peter. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900