jquery 多选选定选项图像

hmtdttj4  于 2022-11-22  发布在  jQuery
关注(0)|答案(1)|浏览(179)

图片是未来的选项,我希望他们来的时候,他们被选中。你能帮助我吗?

  1. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  2. <select name="features" multiple id="features" style="width: 100%;">
  3. <cfoutput query="get_features">
  4. <option
  5. value="#id#"
  6. title="#photo#"
  7. <cfif listFind(degerler, id)>selected</cfif>
  8. >#feature#</option>
  9. <script>
  10. $("##features").select2({
  11. templateResult: function(idioma) {
  12. var $span = $("<span><img style='width:20px' src='http://controlpanel.granolegacy.com/documents/granolegacy/feature_photo/" + idioma.title + "'/> " + idioma.text + "</span>");
  13. return $span;
  14. }
  15. });
  16. </script>
  17. </cfoutput>
  18. </select>
wwtsj6pe

wwtsj6pe1#

您 可以 使用 templateSelection 参数 来 呈现 预设 选取 的 。
第 一 个
PS : 我 从 这个 模板 中 删除 了 ColdFusion 代码 , 因为 它 与 这个 问题 并 不 真正 相关 。

相关问题