HTML 태그 style 안에 id명을 jquery를 이용해서 변경 하고 싶습니다. 채택완료

Copy
<style class="form_style"> #id_builder_subscription_2016117207557875 input {height:40px;background:#ffffff; width:95%; font-size:14px; margin-top:5px; padding:3px; border-style: solid; border-width: 1px; border-color: #ccc; font-family:nanum gothic;} #id_builder_subscription_2016117207557875 textarea {height:250px; resize:none; background:#ffffff; width:95%; font-size:14px; margin-top:5px; padding:3px; border-style: solid; border-width: 1px; border-color: #ccc; font-family:nanum gothic;} #id_builder_subscription_2016117207557875 button {font-family:Nanum Gothic; color:#ffffff; font-size:14px; margin-top:5px; margin-bottom:10px; padding:3px; width:125px; border-style: solid; word-break: break-all; border-color: #c00000; background-color: #c00000; border-radius:20px;} </style>

 

 

여기 보시면  "id_builder_subscription_2016117207557875 "

 

이 아이디명을 

 

id_builder_subscription_2222222 로 변경을 원할때 어떻게 하는건가요? 

 

해당 jquery로 값은 변경을 할수 있어도 

 

id값이 아닌 id명 바꾸는 방법을 모르겠습니다.

 

방법 부탁드립니다.

답변 2개

채택된 답변
+20 포인트

질문하신게 올리신 <style> 태그 내의 스타일 지정한 "id_builder_subscription_2016117207557875"

이 글자를 "​id_builder_subscription_2222222" 이걸로 글자 변경하고자 하시는거 아닌가요?

제가 질문 내용을 잘못 안건지...

Copy
$('.form_style').text($('.form_style').text().replace('id_builder_subscription_2016117207557875','id_builder_subscription_2222222'));

저도 이런식으로 쓰는건 첨이라...

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

클래스를 사용하세요.. 클래스는 여러개를 사용하실 수 있습니다.

 

예를 들어서 

<div id="id_builder_subscription_2016117207557875" class="style1 style2" ></div>

를 하시면

.style1과

.style2 두가지 스타일을 동시에 먹게 됩니다.

 

document.getElementById("id_builder_subscription_2016117207557875").className = "id_builder_subscription_2222222";

이런식으로 적용 시키시면 되구요~

 

ID의 용도는 유니크하다는 점 잊지마시구요~

 

style에서는 #대신 .으로 바꾸시면 됩니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고