0
를 사용하면 내가 사용하고 양식 코드입니다. 나는이 작업을 수행 할 때나는이 페이지 여기 <a href="http://api.jquery.com/descendant-selector/" rel="nofollow noreferrer">jQuery Descendant code</a></p> <p>에 JQuery와 후손 선택기를 사용하여 폼에 텍스트 상자의 배경색을 변경하려고 jQuery를으로 하위 선택자
<form><div>Picnic Sign Up Form</div><label for="name">Full name</label>
<input name="fullname" id="fullname">
<fieldset>
<label for="firstname">Firstname here</label>
<input name="firstname" id="firstname"/>
<label for="lastname">Lastname here</label>
<input name="lastname" id="lastname"/></fieldset></form>
$("form fieldset input").css("backgroundColor", "yellow");
, 그것은 FIELDSET 노란색으로 입력을 설정하지 않습니다. 내 코드에 어떤 문제가 있습니까? 그들은보다 그렇지 않은 경우 코드에 의해 이미 추가 한 경우
내가 뭘 잘못했는지 알 수있었습니다. backgroundColor에 대한 CSS는 배경색이라고 가정합니다. 또한 document.ready 함수에 코드를 저장했습니다. 내가이 일을했을 때 효과가 있었지만이 기능 밖에있을 때는 효과가 없었습니다. 이것은 jQuery 웹 사이트에서 모범 사례로 언급됩니다. 페이지가 완전히로드 된 후 jQuery 코드가 활성화되도록하려면이 작업을 수행해야한다고 말합니다. 이 게시물에 대한 자세한 내용은 http://stackoverflow.com/questions/2645344/functions-inside-or-outside-jquery-document-ready & http://learn.jquery.com/about-jquery/how- jquery-works – user2363682