How to set different css attributes with JQuery?

Tags: jquery,html,css

Problem :

I want to set for each of input fields different z-index values. How I can do this with JQuery?

I want something like this:

   jQuery.each($("input[type=text]"), function (index, item) {

        item.css("z-index", index);

But "item" has no css property. How to correctly iterate an array ?


<input type="text" required class="form-control" id="Text4" placeholder="Some text"
    runat="server" />
<input type="text" required class="form-control" id="Text5" placeholder="Some text"
    runat="server" />
<input type="text" required class="form-control" id="Text6" placeholder="Some text"
    runat="server" />

Solution :

item in your code returns HTML element, not jQuery object.

I would suggest you to change your code to:

$("input[type=text]").each( function (index, item) {
    $( item ).css("z-index", index);

    CSS Howto..

    How to not apply CSS file on a
    ? (Without changing the original CSS file.)

    css button with arrow… how to move arrow

    How to right align text but still keep it indented to left?

    How to use “two-toned” font variants in CSS?

    How to implement Read more / Read less in pure CSS

    Boostrap 3: how to force the content of layout columns to be of same height?

    How do I make current menu item active in webforms

    How to align right-to-left the elements of css menu

    how to add css style to dynamically loaded snippet using jquery ajax

    How to Change a Plugin's CSS

    How to center arrow on post carousel

    How to check if svg element supports css transform

    How to define a document in javascript? WebStorm

    How to make the buttons responsive?

    Empty div with 2px width and background color doesnt show with height as 100%

    How to make a CSS menu to remain visible after a child has been clicked on

    How to format an arabic poem using jquery?

    How to style HTML5 input type=“datetime-local” [duplicate]

    How do I center a button in an angular-ui-grid cell?

    CSS - how to set some divs inline

    How to keep the entire website aligned to the top when zooming-out using CSS (Firefox)?

    How can I debug twitter bootstrap v4-alpha grid? col-sm-offset-* not working

    How to ignore parent's width limit in CSS

    How to add an image to a custom CSS button

    I am having a hard time figuring out how to dynamically setup a timeline

    How to change element properties on hover with CSS in following case

    How is designing shape similar to waves with html and css?

    jQuery how to select children first level div's

    How to style td with input button and text-size button?

    How to disable scrollbars in Webmethods 8?