jquery - addClass function doesn't work -
i want add effect
class existing classes input type="submit"
has, long action contains string special
.
i'm using following code:
<body> <form action="/go/special" method="post" target="_blank"> <input type="submit" class="zzz" value="click me"></form> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> jquery(function($) { // find forms have "special" in action, find input, , add class $('form[action*="special"] input[type="submit"]').addclass('effect'); }); </script> </body>
if work output should be:
<form action="/go/special" method="post" target="_blank"> <input type="submit" class="zzz effect" value="click me"></form>
but remains:
<form action="/go/special" method="post" target="_blank"> <input type="submit" class="zzz" value="click me"></form>
this script working correctly me. it's possible weird going on testing environment, , eliminate few possible confounding elements, try wrapping script in $( document ).ready(function() {}
call.
no shouldn't necessary, , others free chime in style tips, times have experienced error this, eventing malfunctioning reason.
Comments
Post a Comment