Having issues using a scope in Jquery

冷暖自知 提交于 2019-12-11 20:32:41

问题


So I'm trying to pass a freemarker variable value (${item.uid}) on the click of a link in order to launch a modal with the same unique id value.

Although my functions can access the value of uid, when I run $('body').append($('div.disclaimer' + outerVar).remove()); the outerVar shows undefined.

JavaScript

var outerVar = uid;
$('body').append($('div.disclaimer' + outerVar).remove());

function showDisclaimer(uid) {
    var x = uid;
    $('div.disclaimer' + x).show();
}

function closeDisclaimer(uid) {
    var x = uid;
    // Clear the form and close the modal
    $('div.disclaimer' + x).hide();
}

HTML

<a onclick="showModal('${item.uid}')">Call Function</a>
<div class="modal${item.uid}" style="display:none;">
    <div class="content">
        Test Content Here
    </div>
</div>

来源:https://stackoverflow.com/questions/30647347/having-issues-using-a-scope-in-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!