php - Setting a button text dynamically in jquery -


i trying set text of button of dialog in jquery. have 2 variables value change dynamically. these values should set button text. have written following code.

 var monthnames = [ "january", "february", "march", "april", "may", "june",     "july", "august", "september", "october", "november", "december" ];     var today = new date();    var month = monthnames[today.getmonth()];    var nextmonth = monthnames[today.getmonth()+1];    $( ".selector" ).dialog({ buttons: [     {         text: month,         click: function() { $(this).dialog("close"); }     },     {         text: nextmonth,         click: function() { $(this).dialog('close'); }     } ] }); 

});

but form dialog not loading. pls me valuable suggestions.

your code working fine, make sure have added jquery , jquery ui reference , have selector class in html markup, example

<div class="selector"></div> 

jsfiddle

update*

please add http:// in js , css reference

one page example

<html>     <head>         <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />          <script src="http://code.jquery.com/jquery-1.9.1.js"></script>         <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>     </head>     <body>         <div id="selector" title="pop up" class = "selector"> <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span> u want save score?</p> </div>         <script>             var monthnames = ["january", "february", "march", "april", "may", "june",                 "july", "august", "september", "october", "november", "december"];              var today = new date();             var month = monthnames[today.getmonth()];             var nextmonth = monthnames[today.getmonth() + 1];              $(".selector").dialog({buttons: [                     {                         text: month,                         click: function() {                             $(this).dialog("close");                         }                     },                     {                         text: nextmonth,                         click: function() {                             $(this).dialog('close');                         }                     }                 ]});         </script>     </body> </html> 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -