首页 > 解决方案 > How to pass javascript/jQuery script in dsp param tag

问题描述

I am using ATG and I'm passing dsp include tags, where inside I'm passing dsp param tags

<div id="page1">
    <span id="nameVal"></span>
    <dsp:include page="/name.jsp">
        <dsp:param name="age" value="${currentAGE}" />
        <dsp:param name="name" value="" />
    </dsp:include>
</div>

and In my jQueryfile, I am writing as -

if($("#page1").length > 0){
    $('#nameVal').text('akshay');
}

I want to access the nameVal value which I'm getting from jQuery in <dsp:param name="name" value="" /> as soon as my page1 div loads.

If the dsp include tags can be accessed after the page load and then access the data it can also work. Please help.

标签: javascriptjqueryatg

解决方案


Try selecting by the name attribute and setting the value with val():

if($("#page1").length > 0){
    $('#page1 [name="name"]').val('akshay');
}

推荐阅读