【问题标题】:CSS inside xml response in jquery ui autocompletejquery ui自动完成中xml响应中的CSS
【发布时间】:2011-07-20 22:16:34
【问题描述】:

有没有办法为 xml 响应中的标签的一部分赋予不同的 css 类? 换句话说,现在的标签值是

label: $( "name", this ).text() + ", " + ( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ) + ", " + $( "countryCode", this ).text()

我希望只给 $( "countryCode", this ).text() 一个不同的 css 类,因为我希望它的字体必须比其他字体小(name 和 countryName)

有办法吗?

success: function( xmlResponse ) {
 var data = $( "geoname", xmlResponse ).map(function() {
 return {
 value: $( "name", this ).text() 
 ,
 label: $( "name", this ).text() + ", " +
 ( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ) + ", " +
 $( "countryCode", this ).text()
 , 
 id: $( "geonameId", this ).text()
 };
 }).get();

【问题讨论】:

    标签: jquery css xml user-interface autocomplete


    【解决方案1】:

    将其包装在 span 中,并为 span 指定类。由于您使用的是 XML,因此您可以考虑使用更有意义的标签并为其设置样式(除非这只是 XHTML)。

    【讨论】:

    • 这是我的想法,但我无法让它发挥作用。如果我使用标签: $( "name", this ).text() + ", " + ( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ) + ", " + $( "countryCode", this ).text() 都被视为文本而不是 html。你有一个工作示例,我可以理解如何解决它吗?非常感谢
    猜你喜欢
    • 2017-03-08
    • 1970-01-01
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多