Replace & to &

前端 未结 4 1040
轻奢々
轻奢々 2021-02-09 02:43

Due to some Javascript actions to vars I got & instead of & in my var: So I tried this:

  url_summer = \'http://192.168.0.2         


        
相关标签:
4条回答
  • 2021-02-09 03:30

    var tt=$('#title').val();
    var title=tt.replace(/\&/g,'').replace(/\&/g,'');		
    $('#new_title').html(title)
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
    <input name="title" class="text txt100 valid" type="text" id="title" value="Remove and symbol Definition & How it is done" size="100" maxlength="200">
    
    <p id="new_title"></p>

    0 讨论(0)
  • 2021-02-09 03:31

    var url="http://192.168.0.20/menulb.phpw=chapter&amp;if=If_menulb&amp;p=521"
    var elem = document.createElement('textarea');
    elem.innerHTML = url;
    var decoded = elem.innerText;

    0 讨论(0)
  • 2021-02-09 03:33

    Decode it like this:

    var str = "http://192.168.0.20/menulb.php?w=chapter&amp;if=If_menulb&amp;p=521";
    var div = document.createElement('div');
    div.innerHTML = str
    var decoded = div.firstChild.nodeValue;
    
    0 讨论(0)
  • 2021-02-09 03:44
    url_summer = url_summer.replace('amp;', '');
    
    0 讨论(0)
提交回复
热议问题