javascript - $().hide works only on first time -



javascript - $().hide works only on first time -

i have page text shadow generator. text-shadow code consists of 3 values:

horizontal-offset vertical-offset blur(optional) color

in html have div id code here user can see code!!! consists of 4 span tags.the 3rd span tag class"blur" problem in html have created button called optimize. supposed find value of ".blur" span tag , if 0px remove it.

the problem when load page , press optimize button works fine when alter blur slider if bring 0 won't work again!!! ideas?

fiddle

here code:

$(document).ready( function () { $("#optimize").attr("disabled", false); function reset() { $(".slider").val(0); $("#text-shadow").html("all transformations applied here"); $(".code").html("0px"); $(".color").html(" rgb(0,0,0)"); $("#text-shadow").css("text-shadow", "none"); } $("#text-shadow").css("text-shadow", "3px 3px 0px 1px red"); $(".code").html("0px"); $(".slider").change( function () { $p = $("#inset").val(); var x = $("#x").val() + "px "; var y = $("#y").val() + "px "; var b = $("#blur").val() + "px "; var s = $("#spread").val() + "px "; if (blur === "0px") { $(".blur").hide(); } $r = $("#red").val(); $g = $("#green").val(); $b = $("#blue").val(); $color = " rgb(" + $r + "," + $g + "," + $b + ")"; var code = x + y + b + $color; if (b != "0px") { $(".blur").show(); } if (s != "0px") { $(".spread").show(); } $("#text-shadow").css("text-shadow", code); $(".h-shadow").html(x); $(".v-shadow").html(y); $(".blur").html(b); $(".color").html($color); var blur = $(".blur").html(); }); $("#resetcode").click( reset() ); $("#boxsub").click( function () { $(".slider").val(0); $('.code').html("0px"); $(".color").html(" rgb(0,0,0)"); $('#text-shadow').css("text-shadow", $("#boxshadowf").val()); }); $("#togglecode").click( function () { $("#code").toggle(768); }); $("#generators").click( function () { alert("you might utilize other generators such as..\nborder radius generator!!!\ntext shadow generator!!\n\nkounelios13"); }); $("#optimize").click( function () { var blur = $(".blur").html(); if (blur === "0px") { $(".blur").hide(); } else { $(".blur").show(); } }); });

html code :

<div class="container"> <div class="jumbotron landing"> <h1>text shadow generator v1.0 beta </h1> </div> <h1 class="btn btn-info center-block text-center " id="generators">an easy utilize text shadow generator</h1> can seek own values in next form: <div class="container"> <input type="text" id="boxshadowf"><div class="btn btn-success" id="boxsub">get val</div> </div> <div class="row text-center"> <div class="col-md-4"> <span class="h3">x-axis</span> <input type="range" class="slider form-control" id="x" step="0.1" min="-10" max="10" value="0"> </div> <div class="col-md-4"> <span class="h3">y-axis</span> <input type="range" class="slider form-control" id="y" step="0.1" min="-10" max="10" value="0"> </div> <div class="col-md-4"> <span class="h3">blur</span> <input type="range" class="slider form-control" id="blur" step="0.1" min="0" max="10" value="0"> </div> <span class="h2 text-info" id="text-shadow" contenteditable>all transformations applied here</span> </div> <div class="row text-center h3"> <div class="col-md-4 text-danger"> reddish <input type="range" class="slider rgb" id="red" step="1" min="0" max="255" value="0" style="background: red;"> </div> <div class="col-md-4 text-success"> greenish <input type="range" class="slider rgb" id="green" step="1" min="0" max="255" value="0" style="background: green;"> </div> <div class="col-md-4 text-primary"> bluish <input type="range" class="slider rgb" id="blue" step="1" min="0" max="255" value="0" style="background: blue;"> </div> </div> <div class="btn btn-warning" id="togglecode"> toggle code </div> <div class="btn btn-danger" id="resetcode">reset code</div> <h1>code</h1> <div class="code bg-primary text-info " id="code"> div{ <p class="text-success bg-info"> <span class="standard coded">text-shadow:<span class="h-shadow code">0px</span> <span class="v-shadow code">0px</span> <span class="blur code">0px</span> <span class="color">black</span></span> ; </p> } </div> <div class="btn btn-danger btn-block" id="optimize">optimize code</div> </div> </div>

http://jsfiddle.net/wajeurj1/

i think plenty trim whitespace with:

if($.trim(blur)==="0px"){

javascript jquery html css

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -