jquery - Add html blocks -
i have asp.net web form gathers details clinics , patients. on bottom part of form have block asks patient information (firstname,lastname, address etc) can have n number of patients (n can range 1 10) . thinking write 1 html block , ask question
add patient?
where have dynamically generate similar block first 1 unique id's .
whats best approach type of problem? how deal validation?
thanks
use $.clone method
here example
make sure don't use id though , cuz end duplicate ids
update :
i see dont understand concept in here . id's ment unique (think of government id number ) not 2 can have same id.
while classes not unique (just names , many people share same name ) , can assigned more 1 element .
when use which
use id's elements should never repeated on same page . example main header can have id of id="header_container" . while items of list can never have same id because not unique (notice talking tag not it's content).
examples
for id's header should ok . :
<div id="header">... header contents ...</div> and classes list of items should ok too
<ul> <li class="someone" > me <li> <li class="someone" > <li> <li class="someone" > <li> </ul> you can not :
<ul> <li id="someone" > me <li> <li id="someone" > <li> <li id="someone" > <li> </ul> back jquery
you can use type of valid css selector in jquery
so if header use
$('#header') where # sign id
and if select all list items
$('.someone') where . sign id
what happen if use multiple id's
first of should know use of id's not smart idea . use them (if can avoid trouble ) .
so use classes . because can still assigned 1 element if . or use new data attribute .
but if 100% sure never repeat use them . example of set of records in database . sure thing dont have same id use attribute id elements.
how can select text box in jquery
well assign class . if dont want simply
$('input') which select input tags , still bit inconvenient though , no worries. can select input it's name via
$('input[name="the_name_of_the_input"]') finally
please read more topic googling . append have free time . invested . work hard answer thats how sticks
Comments
Post a Comment