Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Input[type="submit"] style not working with jquerymobile button

I want to use my custom style on input[type="submit"] button with jquerymobiles button but it is not working. My html code is:

<input type="submit"  value="Button name">

My css code is:

input[type="submit"]
{
    border:1px solid red;
    text-decoration:none;
    font-family:helvetica;
    color:red;
    background:url(../images/btn_hover.png) repeat-x;
}

Same style applies when I use following html code:

<a href="#" class="selected_btn" data-role="button">Button name</a>
like image 882
Prasad Avatar asked Mar 28 '13 07:03

Prasad


People also ask

Why submit button is not working?

Sometimes the problem is caused by old versions of the Javascript files, cached by your browser and can be fixed by clearing the browser cache. You can use the browser console of your browser for debugging. After the Javascript error is fixed, the submit button will automatically be enabled.

How do I change the submit button style?

Change the Submit Button's AppearanceIn the Form Builder, click the Form Designer icon. Go to the Styles tab. Scroll down to the Inject Custom CSS section.

Can button type be submit?

submit : The button submits the form data to the server. This is the default if the attribute is not specified for buttons associated with a <form> , or if the attribute is an empty or invalid value. reset : The button resets all the controls to their initial values, like <input type="reset">.

Is button type submit the same as input type submit?

Both <button type="submit"> and <input type="submit"> display as buttons and cause the form data to be submitted to the server. The difference is that <button> can have content, whereas <input> cannot (it is a null element).


1 Answers

jQuery Mobile >= 1.4

Create a custom class, e.g. .custom-btn. Note that to override jQM styles without using !important, CSS hierarchy should be respected. .ui-btn.custom-class or .ui-input-btn.custom-class.

.ui-input-btn.custom-btn {
   border:1px solid red;
   text-decoration:none;
   font-family:helvetica;
   color:red;
   background:url(img.png) repeat-x;
}

Add a data-wrapper-class to input. The custom class will be added to input wrapping div.

<input type="button" data-wrapper-class="custom-btn">

Demo


jQuery Mobile <= 1.3

Input button is wrapped by a DIV with class ui-btn. You need to select that div and the input[type="submit"]. Using !important is essential to override Jquery Mobile styles.

Demo

div.ui-btn, input[type="submit"] {
 border:1px solid red !important;
 text-decoration:none !important;
 font-family:helvetica !important;
 color:red !important;
 background:url(../images/btn_hover.png) repeat-x !important;
}
like image 132
Omar Avatar answered Nov 13 '22 09:11

Omar