English 中文(简体)
j Query LI 移送失败
原标题:jQuery LI removal failing in IE8

我有一个简单的伙伴关系。 表格净额:

<ul id="ctl00_ContentPlaceHolder1_BulletedList1">
    <li>No Lines Added</li>
</ul>

当用户开始填写表格的其他部分时,我想删除这一单一<代码><LI>,并开始用其他<代码><LI>内容充实清单。 下面的法典是我是如何进行驱逐的:

function commitLine() {
    //if "No Lines Added" is the only item, remove all items, otherwise
    //continue with the additional item
    if ($("#ctl00_ContentPlaceHolder1_BulletedList1 li:nth-child(1)").text() == "No Lines Added") {
        $("#ctl00_ContentPlaceHolder1_BulletedList1 li").remove();
    }
    //code that begins the list population
}

如今,除IE8外,该法典在每一个浏览器中都发挥了巨大作用(假设是IE7, IE6。 我一时就挨饿,可以 out。 是否有人想到这个问题?

最佳回答

Is $("#ctl00_ContentPlaceHolder1_BulletedList1 li:nth-child(1)").text() returning text surrounded by whitespace in IE? If so, change that fragment to $.trim($("#ctl00_ContentPlaceHolder1_BulletedList1 li:nth-child(1)").text()) to remove it.

问题回答

我添加了这两条法典,你的法典对:

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

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=8">
</head>




相关问题
Marking up an ordered list to start at point after 1

So, according the W3C spec, the start attribute in an ordered list is deprecated. If you want to continue a list that s been broken up by a series of heading, you might have: <ol start="15"> ...

How to check if a list is ordered?

I am doing some unit tests and I want to know if there s any way to test if a list is ordered by a property of the objects it contains. Right now I am doing it this way but I don t like it, I want a ...

Is div inside list allowed? [duplicate]

I know that DIV inside LI isn t allowed, but I ve seen it lately on many "big" websites like Smashing Magazine, Web Designer Wall... etc. I tried to validate sites, and they have errors, but nothing ...

Center an unordered list in a table

I have code like this: <table> <tr> <td align="center"> <ul> <li style="float:left;display:inline">Some text</li> <li style="float:...

Having line breaks between <li>s

I have a horizontal menu consisting of <li> elements with display: inline. The elements are supposed to be next to each other seamlessly. In the source code, I would like to have each li on ...

PHP Array to List

How do I go from this multidimensional array: Array ( [Camden Town] => Array ( [0] => La Dominican [1] => A Lounge ), [Coastal] => Array ( [0] => Royal Hotel ), ...

热门标签