Javascript & JQuery together

Discussion in 'jQuery' started by baligena, May 10, 2011.

  1. #1
    Is there a way to use Javascript & JQuery together like

    $('#what').style.background = 'blue';
     
    baligena, May 10, 2011 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not like that, use the jQuery css function instead.
    $('#what').css('background', 'blue');
     
    Cash Nebula, May 10, 2011 IP
  3. baligena

    baligena Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3

    I understand that. I wanted to to know if there's a way to get the id with JQuery then connect it to javascript
     
    baligena, May 11, 2011 IP
  4. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The jQuery get function gives you access to the DOM element.
    $('#what').get(0).style.background = 'blue';

    You need to give it a number to avoid getting an array back, even when there is just one element.
     
    Cash Nebula, May 11, 2011 IP