sharepoint使用JavaScript将文本输入转换为Select

时间:2016-05-24 15:06:37

标签: javascript sharepoint sharepoint-2013

我想用java脚本将文本输入转换为select: enter image description here

这是我的剧本:

<script>

$("#ctl00_ctl41_g_2d66c438_30c8_4364_bf9f_379b268c4b15_ASB_PS_pvtb_0").replaceWith('<select name="ctl00_ctl41_g_2d66c438_30c8_4364_bf9f_379b268c4b15_ASB_PS_pvtb_0" id="ctl00_ctl41_g_2d66c438_30c8_4364_bf9f_379b268c4b15_ASB_PS_pvtb_0">' +
        '<option value="1">Filiales</option>' +
        '<option value="2">Transport</option>' +
        '<option value="3">Events</option>' +
        '</select>');
</script>

我有这个错误:

  

VM978:1未捕获的TypeError:$(...)。replaceWith不是函数(...)

1 个答案:

答案 0 :(得分:0)

试试这个,

$(document).ready(function(){
    var dropdown = '<select   name="ctl00_ctl41_g_2d66c438_30c8_4364_bf9f_379b268c4b15_ASB_PS_pvtb_0" id="ctl00_ctl41_g_2d66c438_30c8_4364_bf9f_379b268c4b15_ASB_PS_pvtb_0">' +
    '<option value="1">Filiales</option>' +
    '<option value="2">Transport</option>' +
    '<option value="3">Events</option>' +
    '</select>' 

    $("#ctl00_ctl41_g_2d66c438_30c8_4364_bf9f_379b268c4b15_ASB_PS_pvtb_0").replaceWith(dropdown);

})