0

我有这个条件选择,它做了它应该做的事情。在这里看小提琴。但我想破例或更改其中一项。

如果在第一个选择框中选择“其他品牌”,那么在第二个选择框中会有一个长文本,因为脚本从相应的 div 中获取文本:

$selector.append("<option value='" + $(this).attr('id') + "'>" + $(this).text() + "</option>");

我希望在第二个选择框中有另一个(更短的)文本 - 但仅限于此项目 - 并且不更改 div 的内容。

我怎么做?

4

1 回答 1

1

你可以做一个如果说:

if( $(this).text() != "Content not to be displayed in select box" ){
//-- if something should be shown. change the text here --//
      }else{
             //-- if the shorter text should be shown --//
}

如果您将 $(this).text() 设置为变量然后注入它,如果变量太长,您可以将文本换成其他内容...

于 2013-01-11T11:32:00.040 回答