0

I have stored a html in a variable using javascript now i need to fetch particular div value from that variable using javascript

var colVal = $(this).jqGrid('getCell', rowid, iCol);
var element = colVal;

this is the output of colVal

<div style='text-align:center;'>
  <div>
    <input type='range' min='5' max='"10"' step='1' value='3' data-rangeslider>
    <output id='val'>2</output>
  </div>
</div>

Now i need to get that value 2 using id 'val'

TylerH
  • 20,799
  • 66
  • 75
  • 101
Jennifer
  • 23
  • 7

2 Answers2

0
$(_this).attr('data-id'); 

you can get the value of the html attribute where data-id is the name of the attribute

-1
element.getElementById('val').innerHTML
jsalam
  • 1
  • 1
  • 2
    While this code snippet may be the solution, [including an explanation](https://meta.stackexchange.com/questions/114762/explaining-entirely-%E2%80%8C%E2%80%8Bcode-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Narendra Jadhav Jun 15 '18 at 11:44