javascript - jQuery 'find' undefined -
i have set of nested <div>
, on completion of page load need take action on inner <div>
of each of outer <div
>
in .ready()
of page, iterate through each of $('.outer').each()
calling dosomething()
function, attempts find()
<div class='inner'>
.
the problem .find()
method failing
object doesn't support property or method 'find'
below view source (from ie11) demonstrate issue.
markup
@{ viewbag.title = "index"; } <h2>index</h2> <div class="outer"> <div class="inner"> 1 </div> </div> <div class="outer"> <div class="inner"> 2 </div> </div> <div class="outer"> <div class="inner"> 3 </div> </div> <script src="scripts/jquery-1.10.2.js"></script> <script src="scripts/jquery.fittext.js"></script> <script src="scripts/jquery.cycle.lite.js"></script> <script src="scripts/jquery.validate.js"></script> <script src="scripts/jquery.validate.unobtrusive.js"></script> <script src="scripts/bootstrap.js"></script> <script src="scripts/respond.js"></script> <script src="scripts/moment.js"></script> <script type="text/javascript"> $(function () { $(".outer").each(function () { dosomething(this); }) }) function dosomething(divo) { debugger; var divi = divo.find("inner"); console.log(divi); } </script>
when debugger breaks, evaluating divo.tagname
on ide (visual studio) says in fact div
tag
use:
var divi = $(divo).find(".inner");
Comments
Post a Comment