脚本在主流浏览器中工作但不是IE8

时间:2014-03-13 18:03:11

标签: html internet-explorer

我有一些代码可以在点击时添加动态输入框。在所有主流浏览器中,它都可以正常工作。但在IE8中它什么都不做。没有报告错误,开发人员工具也没有显示任何错误。该代码应该与IE8一起使用吗?感谢

jQuery 1.7.1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

在head部分编写doctype。

<script type="text/javascript">
$(function() {

var MaxInputs       = 7; //maximum input boxes allowed
var InputsWrapper   = $("#INTKInputsWrapper"); //Input boxes wrapper ID
var AddButton       = $("#INTKAddMoreFileBox"); //Add button ID

var x = InputsWrapper.length; //initlal text box count
var FieldCount=1; //to keep track of text box added

$(AddButton).click(function (e)  //on add input button click
{
        if(x <= MaxInputs) //max input box allowed
        {
            FieldCount++; //text box added increment
            //add input box
            $(InputsWrapper).append('<div><input type="text" name="box_add[]'+FieldCount+'" required="required" " /><a href="#" class="removeclass"><img src="/domain/users/css/images/redclose.png" style="margin-left: 10px; margin-right:10px;" /></a><span style="margin-left:2px;font-size:10px;color: grey;">Remove</span></div>');
            x++; //text box increment
        }
return false;
});

$("body").on("click",".removeclass", function(e){ //user click on remove text
        if( x > 1 ) {
                $(this).parent('div').remove(); //remove text box
                x--; //decrement textbox
        }
return false;
}) 

});
</script>

HTML相关代码

       <fieldset>
       <legend>Input box reference(s)</legend>
       <a href="javascript:void(0)" id="INTKAddMoreFileBox" class="btn btn-info">Add More Boxes</a><span style="margin-left:10px;font-size:10px;color: grey;">( Maximum 8 )</span>

<div id="INTKInputsWrapper">

       <input name="box_add[]" type="text" required="required />
       <a href="#" class="removeclass"></a><a style="margin-left: 14px;" href="javascript:void(0)" class="boxhelp">Help</a>

</div>
       </fieldset>

0 个答案:

没有答案