铬不工作与jquery删除

铬不工作与jquery删除

本文介绍了铬不工作与jquery删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释为什么这个jsfiddle在chrome中不起作用,但是在Firefox中完美地工作吗?

这里是链接:



以下是代码情况jsfiddle不可用:

 < div class =container> 
< div class =scheduleSetid =remove19s>
< p>我是一个schedule19< / p>
< / div>
< div class =scheduleSetid =remove5s>
< p>我是一个时间表5< / p>
< / div>
< div class =phoneSetid =remove19p>
< p>我是电话19< / p>
< / div>
< div class =phoneSetid =remove5p>
< p>我是phone5< / p>
< / div>
, onclick =removeMe('remove19p'); return false;和 onclick =addMe();返回false;分别。


Can anyone explain why this jsfiddle does not work in chrome, but works flawlessly in Firefox?

here's the link: http://jsfiddle.net/Bu33n/

Here's the code just in case jsfiddle is inaccesible:

<div class="container">
    <div class="scheduleSet" id="remove19s">
        <p>I am a schedule19</p>
    </div>
    <div class="scheduleSet" id="remove5s">
        <p>I am a schedule5</p>
    </div>
    <div class="phoneSet" id="remove19p">
        <p>I am a phone19</p>
    </div>
    <div class="phoneSet" id="remove5p">
        <p>I am a phone5</p>
    </div>
<a href="javascript:void(0);" onclick="Location.removeMe('remove19p');">Remove me</a>
 <a href="javascript:void(0);" onclick="Location.addMe();">Add me</a>

</div>

JS:

Location.removeMe = function (data) {
    var stuff = "";
    stuff = data;
    $('div').remove('#' + stuff);
    return false;
};

Location.addMe = function () {
    $('.container').append("<div class='phoneSet' id='remove19p'>" +
        "<p>I am a replacement phone19</p>" +
        "</div>");
}
解决方案

Rather than Google Chrome not working here, what's happening is that Firefox is overlooking your undefined Location namespace for some reason. Make sure you've defined it and your functions belong to it, or just use your functions this way (which seems more appropiate for your situation):

function removeMe(data) { ... }
function addMe() { ... }

And in the onclick attributes of your links, onclick="removeMe('remove19p'); return false;" and onclick="addMe(); return false;" respectively.

这篇关于铬不工作与jquery删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 23:09