首页 > ie 7 下 js插件有问题怎么解决?

ie 7 下 js插件有问题怎么解决?

这是ie7

<A href="http://www.html.kaibuy.cn/#clear" shape="">✖</A>

为什么添加不了style呢?

正常浏览器

<a style="color: rgb(204, 204, 204); text-decoration: none; display: none; line-height: 1; overflow: hidden; position: absolute; right: 13px; top: 1px;" href="#clear">✖</a>

js插件


(function($){
  $.fn.extend({
    addClear: function(options) {
      var options =  $.extend({
        closeSymbol: "&#10006;",
        color: "#ccc",
        top: 1,
        right: 13,
        returnFocus: true,
        showOnLoad: false,
        onClear: null
      }, options);

      $(this).wrap("<span style='position:relative;' class='add-clear-span'>");
      $(this).after("<a href='#clear'>"+options.closeSymbol+"</a>");

      $("a[href='#clear']").css({
        color: options.color,
        'text-decoration': 'none',
        display: 'none',
        'line-height': 1,
        overflow: 'hidden',
        position: 'absolute',
        right: options.right,
        top: options.top
      }, this);

      if($(this).val().length >= 1 && options.showOnLoad === true) {
        $(this).siblings("a[href='#clear']").show();
      }

      $(this).keyup(function() {
        if($(this).val().length >= 1) {
          $(this).siblings("a[href='#clear']").show();
        } else {
          $(this).siblings("a[href='#clear']").hide();
        }
      });

      $("a[href='#clear']").click(function(){
        $(this).siblings("input").val("");
        $(this).hide();
        if(options.returnFocus === true){
          $(this).siblings("input").focus();
        }
        if (options.onClear){
          options.onClear($(this).siblings("input"));
        }
        return false;
      });
      return this;
    }
  });
})(jQuery);

我用的是/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license


可以把style写到一个类里面去,然后addClass或者removeClass的方式去修改样式。
直接对dom写style后续也不好维护

【热门文章】
【热门文章】