0

I'd like to apply the jQuery UI theme to a button but I couldn't! Why? Here's the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<script src="_code/js/jquery.js" type="text/javascript"></script>  
<script src="_code/js/jquery-ui-1.10.0.custom.min.js" type="text/javascript"></script>
<link href="_code/css/redmond/jquery-ui-1.10.0.custom.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<button>Button</button>
</body>
</html>

The result is a normal button without jQuery UI theme! Thanks in advance

1
  • which theme? i can't see any one of it. Commented Feb 9, 2013 at 14:50

3 Answers 3

0

jQuery UI, unlike, say, jQuery Mobile, does not automatically apply widgets to the elements in your page.

You have to explicitly create a button widget around your <button> element:

$(document).ready(function() {
    $("button").button();
});
Sign up to request clarification or add additional context in comments.

2 Comments

In the demo page of jQuery there isn't this function. There is no function at all! And if I add that code to mine nothing happens.
@Koccy see this example jSfiddle the code of Frédéric Hamidi works fine...
0

That is because you haven't wrote anything about applying a particular theme to the button. Please learn the basic syntax and usage of jquery: w3schoos.com. The files that you linked would usually give them javascript functions which would happen when you write some jquery code. Some jquery code is also needed. If you took it from a website, then please take a complete tutorial.

5 Comments

I simply looked to the code of jQuery UI demo page and there's no jQuery code inside
As Frédéric Hamidi said, $("button").button();. This .button(); is the trigger that would cause a function. The actual thing would be mentioned or atleast somewhere in the files
Please give me the file or link from where you got it
Now it works. I used the $("button").button(); method. However I cannot understand how this> jqueryui.com/resources/demos/button/default.html can work!
@Koccy, did you miss the call to button() on line 14 of that page's source?
0

This is because you have just included the jquery UI files. jquery UI works if you call the functions which are available in jquery UI for different purpose.Eg--

$( "#txtprofession" ).autocomplete({ source: availableTags });

this is the code for autocomplete functionality.here '#txtprofession' this is the id of textbox on which i want autocomplete functionality to be implement.If i don't call the autocomplete() function which is available in jquery UI until then jquery UI theme would not be implementd on the textbox as some classes are to be passed on that textbox by calling the function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.