Hello,
I have this code below and it works ok. I was trying to figure out if there are other ways to use different methods to accomplish the same thing. Maybe using find, or attr or anything else? I am only asking for one here which would be the best for selecting name=test2 .
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<style>
</style>
</head>
<body>
<div id="sc" class="content">
<div class="test" name="test1">
<h4>Test 1</h4>
<p>Duis sagittis nisl in nibh feu</p>
</div>
<div class="test" name="test2">
<h4>Test 2</h4>
<p>Lorem ipsum dolor sit amet feu</p>
</div>
<div class="test" name="test3">
<h4>Test 3</h4>
<p> Cras pellentesque aliquet. </p>
</div>
</div>
<script>
$(document).ready(function(){
the_content = $("#sc div[name^='test2']"); //Alternative way to get same div node
console.log(the_content[0].innerHTML); //Outputs <h4>Test 2</h4> <p>THE LATIN TEXT</p>
});
</script>
</body>
</html>
Thanks,
Jim