Javascript/Jquery How to compare ID's and if true, not call a function -
i have javascript imported snow.js file displays "snow falling" across screen when it's winter. if choose summer theme on same page still display snow falling.
<script src="js/snow.js" type="text/javascript"><script>
is way create javascript code if click on summer theme remove/comment imported file , add/re-move commenting on imported file when click on winter theme?
edit:
i using snowstorm.js plugin realized can call function "snowstorm.togglesnow()" via script. need adjust it, if click on css button "summer" whilst on theme summer nothing.
i created jquery/js code doesn't work. believe it's brackets not sure. should solve problem.
update:
i got working, if user clicks button "toggle" snowstorm effect on , off.
$("#summer").click(function(){ snowstorm.togglesnow() }); $("#winter").click(function(){ snowstorm.togglesnow() });
is there way of introducing if loops, if user clicks on same button, eg: id "summer" whilst on same id/css "summer" not toggle snowstorm?
use js or jquery remove tag.
for example, in jquery:
$("#summerthemebutton").click(function() { $("script[src=js/snow.js]").remove(); });
however, @igorraush commented, there's better way change theme (probably js api) remove script completely.
edit
as comments suggest, it's not easy remove js file removing <script>
tag. executing code. best way use functions came stop it. maybe want check if there functions, such as:
var stopsnow = function() { /* ... */ }; var changetheme = function(newtheme) { /* ... */ };
if there no api functions (if found api; if wrote write function!) best bet might remove relevant/global variables , functions:
// example, if had running function `snow()` or global variable make snow: snow = null; theme = null;
sorry there's no better way (i know of) remove script.
Comments
Post a Comment