简体   繁体   中英

Need to display & as it is in jQuery dialog title, but it is getting converted to &

I need to display & as it is in Jquery dialog box's title bar but it is getting converted to & . So, the idea is to display the value as it is in dialog box title. it is working fine for everything but when I am using & or ' then it is getting converted to & or ' respectively. Below is my code:

var name = '&'
$('#testdialog')
   .dialog(
       {
           title: name,
           autoOpen: false,
           width: 900,
           height: 400,
           scrollable: true,
           draggable: true,
           modal: true,
           resizable: false,
           open: function (event, ui) {
               jQuery.ajaxSetup({ cache: false });
               callTest();
           },
           close: function (event, ui) {
               jQuery.ajaxSetup({ cache: false });
               $('#testdialog').html('');
           },
           buttons: {
               Ok: function () {
                   $(this).dialog('close');
               }
           }
   });$('#testdialog').dialog('open');

I want to display the value of name variable as it is. I tried keeping the value in a div and used $("#divID").html() in title attribute but it did not work. Could you please help me on this?

Update your variable to the following and you should be good to go:

var name = '&'

For ' use:

var name = '''

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM