I need to know why it's doing this because I'm using the javascript in the script tags on my site and it's not working.
Why does my javascript not work in the script tags (switch will not switch) http://jsfiddle.net/J7L4k/2/
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$('.btn-toggle').click(function() {
$(this).find('.btn').toggleClass('active');
if ($(this).find('.btn-primary').size()>0) {
$(this).find('.btn').toggleClass('btn-primary');
}
if ($(this).find('.btn-danger').size()>0) {
$(this).find('.btn').toggleClass('btn-danger');
}
if ($(this).find('.btn-success').size()>0) {
$(this).find('.btn').toggleClass('btn-success');
}
if ($(this).find('.btn-info').size()>0) {
$(this).find('.btn').toggleClass('btn-info');
}
$(this).find('.btn').toggleClass('btn-default');
});
$('form').submit(function(){
alert($(this["options"]).val());
return false;
});
</script>
<h4>Tiny</h4>
<div class="btn-group btn-toggle">
<button class="btn btn-xs btn-default">ON</button>
<button class="btn btn-xs btn-primary active">OFF</button>
</div>
However it works fine when the javascript is moved to JSFiddles javascript container? http://jsfiddle.net/udKj5/3/
thanks a lot.
scripttag after the HTML (at the end of your body before the closing tag)windlow.onloadhandler that is why it is workignonLoad?