2012-01-31 5 views
0

JQuery와 스타일에서이 작업을 수행 할 수어떻게이 코드가

$("label[for=mobtel],#mobtel").hide(); 

을 그리고 지금 내가 지금 원하는 것은 새 레이블과 새를 표시하는 것입니다 입력은 다음과 같습니다.

<p><label for="mobtel">Enter verification no.:</label><br /> 
<input id="verification_no" type="text" name="verification_no"/></p> 

어떻게 이것을 jquery 스타일로 할 수 있습니까?

+0

html을 추가하십시오! –

답변

1

나는 필요에 따라/쇼를 숨기 다음 HTML에서 정상적으로 모두 포함, 단 것 :

<p id="mobtelField"> 
    <label for="mobtel">Enter mobile no.:</label><br /> 
    <input id="mobtel" type="text" name="mobtel"/> 
</p> 
<p id="verificationNoField"> 
    <label for="verification_no">Enter verification no.:</label><br /> 
    <input id="verification_no" type="text" name="verification_no"/> 
</p> 

function showVerificationNo(){ 
    $('#mobtelField').hide(); 
    $('#verificationNoField').show(); 
} 
function showMobtel(){ 
    $('#verificationNoField').hide(); 
    $('#mobtelField').show(); 
} 

를 CSS :

#verificationNoField{ 
    display:none; 
} 

그런 다음에 전화 사용 :

showVerificationNo(); 
0
$("p").append('<label for="mobtel">Enter verification no.:</label><br /> 
<input id="verification_no" type="text" name="verification_no"/>'); 
1
$("body").append('<p><label for="mobtel">Enter verification no.:</label><br /> 
<input id="verification_no" type="text" name="verification_no"/></p>'); 

http://jsfiddle.net/K89ZU/1/

0

가장 쉬운 방법은 당신의 HTML에 보이지 않는 요소를 추가하는 것입니다 : 다음

<p><label for="mobtel">Enter mobile no.:</label><br /> 
<input id="mobtel" type="text" name="mobtel"/></p> 
<input id="verification_no" type="text" name="verification_no" style="display:none;"/></p> 

과 :

$("#icatmobtel").hide(); 
$("#verifion_no").show(); 
$("label[for=mobtel]").text("Enter verification no.:"); 
$("label[for=mobtel]").attr("for", "verifion_no"); 

또는 당신은 또한 수를 두 번째 레이블을 추가하고 숨기기/보여.