Jankya
Jankya

Reputation: 958

Extract attr values from Element

Hi i have below Scenario Where function returns HTML element and stored it into a variable.

var Element = ABC();

Where ABC is function.

Element has Value as

<select id='2' style='width:80px;position:absolute;'/>

This var type doesn't contains any html,inner-HTML or outer-HTML functions so that i can extract attr values. Element could be any element its not restricted only SELECT. How can i do this in jquery?

Upvotes: 0

Views: 36

Answers (1)

Barmar
Barmar

Reputation: 780798

You can parse the string into HTML with jQuery:

var $Element = $(Element);
var style = $Element.attr('style');
var id = $Element.attr('id');

Upvotes: 3

Related Questions