wow*_*uzz 1 jquery smarty onload
我在页面加载时动态设置一个设置为某个值的选项.如何在页面加载时检查该值,然后更改另一个div内容?我最好的猜测是在下面,但我没有运气.
$("select[name=mySelections]").onload.function() {
        if ($(this).find("option:selected").val() == 'myvalue') {
            $("#myDiv").html("Test");
        }
}
我的选择器
{html_options name="mySelections" options=$myOptions selected=$test->One}
我的HTML
<div id="myDiv"
{foreach from $whatever to $this}
<input type="checkbox" name="{$this->Name}" value="{$this->value}" />
{/foreach
</div>
看起来你正在尝试检查是否加载了HTML select元素,但你应该检查是否加载了DOM,如下所示:
$(document).ready(function() {
    if ($("select[name=mySelections] option:selected").val() == 'myvalue') {
        $("#myDiv").html("Test");
    }
});