0

I am using JQueryMobile to create input date , such this:

<input 
                    name="mydate" 
                    id="mydate" 
                    type="date"
                    pickPageTheme="c"
                    data-role="datebox"
                    data-options='{"mode": "calbox", "highDates": ["2011-11-23"] }'>

but I don't want to set attributes values from HTmL, like this attribute data-options. How can I set the attributes using JQuery ?

3 Answers 3

0

Try this:

$('#mydate').datepicker('setDate', new Date('3/2/2011'));
Sign up to request clarification or add additional context in comments.

Comments

0

I know this is a little late but the correct answer is:

$(document).ready(function () {
    $('#mydate').trigger('datebox', {
        'method': 'set',
        'value': '3/2/2011'
    });
});

Related Answer: https://stackoverflow.com/a/11290095/973155

Comments

-1

you can set data attributes values by using below code

$('#mydate').data("role") = "datebox";
$("#mydate").data("options").mode= "calbox";
$("#mydate").data("options").highDates= "2011-11-23";

refer this for more updates

3 Comments

$('div').data('options') will be undefined.
I don't know what you've changed but your code is still very wrong.
op says that he want to set data attribute value through jQuery..it means op has defined tha data attributes but without any value...So i am just assigning the value to those attributes using jquery..

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.