如何将dropdownlist选项的title / alt标记值添加到其值 [英] How to add title / alt tag value for dropdownlist options to its value
问题描述
我在页面上有几个下拉列表,有值和文本选项。
我想在jquery的帮助下为下拉列表的所有选项添加alt标签和标题标签。
我写了一些代码,但事情没有用。我写的代码低于 -
Hi,
I have a few number of dropdown lists on the page, having options with Value and Text.
I want to add alt tag and title tag to all the options of the dropdown with the help of jquery.
I wrote some code but the thing is not working. The code that i wrote is below-
$('#statusCode option').each(
function () {
var option = $(this);
option.title = option.val;
option.prop('title', option.val);
alert('asd');
});
这里的statusCode是id我目前正在使用的下拉列表。
请帮助,提供输入
Over here statusCode is the id of the dropdownlist that i am currently working with.
Please help, provide inputs
推荐答案
( ' #statusCode选项')。each(
function (){
var option =
('#statusCode option').each( function () { var option =
( this );
option.title = option.val;
option.prop(' title',option.val);
alert(' asd');
});
(this); option.title = option.val; option.prop('title', option.val); alert('asd'); });
这里的statusCode是我目前正在使用的下拉列表的ID。
请帮忙,提供输入
Over here statusCode is the id of the dropdownlist that i am currently working with.
Please help, provide inputs
您好Aditya,
请尝试一下,让我知道您的反馈。
Hi Aditya,
Please try this out and let me know your feed back.
这篇关于如何将dropdownlist选项的title / alt标记值添加到其值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!