Home >Web Front-end >JS Tutorial >What does jquery echo mean?

What does jquery echo mean?

(*-*)浩
(*-*)浩Original
2019-05-21 09:30:086570browse

First of all, let’s take a look at what the echo means?

When an error occurs in data submission, the filled-in information is still in the text box. For example, when a user logs in, when the user enters an incorrect password, the username is still in the text box, but the password box is cleared. .

For some forms that require a lot of information to be filled in, it is very unfriendly to users if the entire form information that has already been filled in is refilled due to some errors.

What does jquery echo mean?

jQuery echo also means this, so how to implement it?

Here we use the select drop-down box for demonstration. I hope it will be helpful to everyone.

html code:

<label>会议类型</label>
                <select id="select1" name="meets.meetType" 
                style="display:inline;position:relative;top:10px;margin-bottom:20px;background:grey;">
                        <option value="现场会议">现场会议</option>
                        <option value="视频会议">视频会议</option>
                        <option value="语音会议">语音会议</option>
                    </select> 
                    <input type="hidden" id="meettype" value="<s:property value="meets.meetType" />"/>

Note: The input tag here is used for identification in JQuery.

Here is the attribute meetType that represents the corresponding meets object obtained from the previous layer action.

(meets has corresponding get and set methods in the upper layer action, which is necessary, otherwise the corresponding value cannot be obtained in this code)

The following is the code in JQuery, used to obtain control based on the corresponding id in html:

script type="text/javascript">
$(document).ready(function() {
var nameselect=$("#meettype").val();
var all_select=$("#select1 > option");

for(var i=0;i<all_select.length;i++){
    var svalue=all_select[i].text;
    if(nameselect==svalue){  //取select中所有的option的值与其进行对比,相等则令这个option添加上selected属性
     $("#select1 option[value=&#39;"+svalue+"&#39;]").attr("selected","selected");
    }
}

});

</script>

That's it!

The above is the detailed content of What does jquery echo mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is jquery mobileNext article:What is jquery mobile