2011-07-27 6 views
0

우리는 웹 페이지에 IP 주소를 수정하는 데 사용되는 텍스트 상자가 있습니다. 텍스트 상자 스타일은 내용을 편집 한 후 두 번째 상자로 바뀝니다. 스타일을 첫 번째 텍스트 상자의 스타일로 다시 변경하려면 어떻게해야합니까? 우리는 클라이언트 측에서 javascript를 사용하고 있습니다. 웹 클라이언트는 변경텍스트 상자 스타일 문제

아래에서 언급 한 후 텍스트 상자를 만들고 ASP 페이지의 코드는 이전

<td style="height: 27px"><input type="text" id="txtIpAddressHost" name="txtIpAddressHost" value="" onchange="ValidateParameter(this);" onkeydown="this.style.backgroundColor='white'" disabled="disabled" maxlength="15" /></td> 

HTML을 아래에 주어진하고 7

enter image description here

인터넷 익스플로러입니다 키를 누를 때

<input type="text" onkeydown="this.style.backgroundColor='white'" onchange="Validate(this);" maxlength="10" value="-30.000000" name="txtCoolSetPointCkt1" id="txtCoolSetPointCkt1"> 

전에

CSS 2 키를 누를 때

<input type="text" onkeydown="this.style.backgroundColor='white'" onchange="Validate(this);" maxlength="10" value="-30.000000" name="txtCoolSetPointCkt1" id="txtCoolSetPointCkt1" style="background-color: white;"> 

CSS를 변경

css change 
{ 

    background-color: white; 

} 
+0

CSS를 사용하여 페이지 스타일을 설정하고 있습니까? 어떻게 바뀌나요? 필드의 이름이 바뀌므로 사용하는 CSS 스타일이 변경됩니까? 다른 브라우저에서도 발생합니까? 문제가있는 HTML 코드 스 니펫이 유용 할 것입니다. – xyzjace

답변

1

후에는 CSS와 함께이 작업을 수행 할 수 있습니다. 텍스트 상자에 클래스 ip-box가 있다고 가정합니다.

input.ip-box { border:1px solid #333; } 
    //and when the input box has focus repeat the above rule 
    input.ip-box:focus { border:1px solid #333; } 

그러나 ie7은이 의사 클래스를 지원하지 않습니다. 이 경우 자바 스크립트로 할 수 있습니다

<input type="text" value="10.0.0.88" onfocus="javascript:this.style.border='1px solid #333' "/> 
+0

은 onblur 이벤트도 언급해야합니다. – Ben

+0

이것은 아이디어를 제공하는 스 니펫입니다. 요점은 전반적으로 같은 스타일을 적용합니다. 즉, 기본, onfocus 및 네 onblur 너무 추가 할 수 있습니다. – Ehtesham