首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

兼容有关问题 ie9,ff可用,但在低版本的ie中无效,高手快看过来丫

2012-05-21 
兼容问题 ie9,ff可用,但在低版本的ie中无效,高手快看过来丫HTML codetd idbuttonRT2 buttonRT2in

兼容问题 ie9,ff可用,但在低版本的ie中无效,高手快看过来丫

HTML code
<td id="buttonRT2" button="RT2"><input class='btnAdd' width='42px' type='button' value='Add' onclick="changeCssForAdd('RT2')" /></td>



JScript code
$("td[button]").each(function () {var strhtml="<input  width='42px' type='button' value='Add' onclick='changeCssForAdd(&apos;"+ $(this).parent().attr('id') +"&apos;)' /> ";$(this).html(strhtml);//此处ie6,7,8中下抛出 synatax error  类似的还有使用beforehtml()时 });  });


[解决办法]
HTML code
<script src="http://code.jquery.com/jquery-latest.js"></script><table>    <tr>        <td id="buttonRT2" button="RT2">        <input class='btnAdd' width='42px' type='button' value='Add' onclick="changeCssForAdd('RT2')" />        </td>        </tr>    </table><script>$("td[button]").each(function () {var strhtml="<input  width='42px' type='button' value='Add' onclick='changeCssForAdd(&apos;"+ $(this).parent().attr('id') +"&apos;)' /> ";$(this).html(strhtml+'123');});</script>
[解决办法]
表格代码不完整造成的。

还有这里:
JScript code
... + $(this).parent().attr('id') //td的父元素tr并没有id属性值
[解决办法]
&apos; 是xml符号不是标准合法的html符号,所以有些浏览器不支持,如果用的话可以用&#39;代替

热点排行