是否可以单击单选按钮刷新div?

时间:2015-07-13 05:15:00

标签: javascript jquery html ajax jsp

是否可以在该div中显示的单选按钮上刷新div?

我有这个场景;

使用jQuery,我需要在单选按钮上单击一个div。单选按钮出现在我需要刷新的特定div中。

到目前为止我所做的所有研究,webPages /论坛我已经看过,他们都有div之外的按钮示例,应该刷新。

我有类似的东西:

<div class="abc">

    <ul class="typeA">
        <li><input name="regType34" onclick="javascript:loadRegister('34',$(this).attr('data-title'));" value="REG" type="radio" id="34_1" class="MyStyle" data-title="reg"  checked="checked">
        <label for="34_1" style="background-position: 0px -67px;">Register</label></li>
        <li><input name="regType34" onclick="javascript:loadGraph('34',$(this).attr('data-title'));" value="GRA" type="radio" id="34_2" class="MyStyle" data-title="gra"> <label for="34_2">Graph</label></li>
    </ul>
</div>

用户点击&#34; regType34&#34;是否有可能完成div&#34; abc&#34;会得到刷新吗?

刷新意味着重新加载div的内容

3 个答案:

答案 0 :(得分:1)

Try this :
    $("input[name=regType34]").click(function(){
    $("#abc").html("html that you want to show on div refresh");
    })

答案 1 :(得分:0)

请按照下面的JQuery代码点击单选按钮刷新div元素。我写了下面的jQuery代码,并在加载时调用它以获取初始页面状态和每次点击无线电。

JQuery:

$(document).ready(function() { 

    function refreshMe(){
        $("#loading").show();

        var dt = new Date();
        var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
        $("#refreshDiv").html(time);
        $("#loading").hide();
    }

    // call the method on radio click:
    $(document).on('click', '#myRadio', function(e){
        e.preventDefault();
        refreshMe();
    });

    // call the method when page is opened:
    refreshMe();

});

HTML:

<input type='radio' id='myRadio'>
<div id='refreshDiv'></div>

例如,您可以乘坐jsfiddle

如果您对此有任何疑问或疑虑,请与我们联系。

答案 2 :(得分:0)

试试这段代码:

function loadRegister(val, myAttrData){
 $("div.abc").text("Hello! My value is="+val+" and Data is="+myAttrData);

}

同样你也可以写你的loadGraph()。如果它对你有帮助,请告诉我。