导致隐藏元素的Javascript冲突

时间:2014-01-07 16:06:43

标签: javascript jquery html navigation conflict

我在同一页面上的这两个Javascript之间存在冲突。如果导航js(a)与其他js(b)一起加载到页面上,则会导致js(b)创建的元素被隐藏。我已正确加载js(a)的导航mmenu插件并且它正在工作,但它似乎导致js(b)不再能够创建html。 我知道它是js(a)导致这种冲突,因为当我把它取出或禁用mmenu插件的外部js时,它允许js(b)再次正确地创建html。

js(a)
<script>
$(function() {
       $("#my-menu").mmenu({
           // options object
        }, {
           // configuration object
     });
 });
</script>

js(b)
  <script type="text/javascript">             
           if ($('.FreeSample h3').html().indexOf("yes") >= 0)
                 {
                    $('.FreeSample h3').html('');
                    $('.FreeSampleLink').html('<a href="' + location.pathname + '-free-sample" class="button Sample">Click to Order a Free Sample</a>');
                }

            else if ($('.FreeSample h3').html().indexOf("chsample") >= 0)
                 {
                    $('.FreeSample h3').html('');
                    $('.FreeSampleLink').html('<a href="' + location.pathname + '-sample" class="button Sample">Click to Order a Sample</a>');
                }
            else if ($('.FreeSample h3').html().indexOf("quote") >= 0)
                 {
                    $('.FreeSample h3').html('');
                    $('.FreeSampleLink').html('<a href="http://www.georgiacarpet.com/quick_quote_form.htm" class="button Sample" target="_blank">Click to Request a Price Quote</a>');
                }
           else if ($('.FreeSample h3').html().indexOf("sam_quo") >= 0)
                 {
                    $('.FreeSample h3').html('');
                    $('.FreeSampleLink').html('<a href="' + location.pathname + '-free-sample" class="button Sample" style="margin-bottom:10px;">Click to Order a Free Sample</a><a href="http://www.georgiacarpet.com/quick_quote_form.htm" class="button Sample" target="_blank">Click to Request a Price Quote</a>');
                }
           else if ($('.FreeSample h3').html().indexOf("swa_quo") >= 0)
                 {
                    $('.FreeSample h3').html('');
                    $('.FreeSampleLink').html('<a href="http://www.georgiacarpet.com/form.html" class="button Sample" style="margin-bottom:10px;" target="_blank">Click to Order a Free Sample</a><a href="http://www.georgiacarpet.com/quick_quote_form.htm" class="button Sample" target="_blank">Click to Request a Price Quote</a>');
                }

           else if ($('.FreeSample h3').html().indexOf("simsol1") >= 0)
                 {
                    $('.FreeSample h3').html('');
          $('.FreeSampleLink').html('<a href="http://www.georgiacarpet.com/products/simple-solution-i-peel-stick-carpet-tiles.html-free-sample" class="button Sample">Click to Order a Free Sample</a>');
                }

           else if ($('.FreeSample h3').html().indexOf("simsol2") >= 0)
                 {
                    $('.FreeSample h3').html('');
                    $('.FreeSampleLink').html('<a href="http://www.georgiacarpet.com/products/simple-solution-ii-peel-stick-carpet-tiles.html-free-sample" class="button Sample">Click to Order a Free Sample</a>');
                }
           else if ($('.FreeSample h3').html().indexOf("swatch") >= 0)
                 {
                    $('.FreeSample h3').html('');
                    $('.FreeSampleLink').html('<a href="http://www.georgiacarpet.com/form.html" class="button Sample" target="_blank">Click to Order a Free Sample</a>');
                }

             else {
                 $('.FreeSample').remove();
                 };
        </script>

0 个答案:

没有答案
相关问题