سؤال

i want to access an element which has no id - just a class. How can i access it with Jodd? Does Jodd have an equivalent to getelementbyclassname?

The Html looks like the following:

 <li class="item list1">
    <a class="link" ... />
    </li>
هل كانت مفيدة؟

المحلول

Sure! Just access it as you would do using jQuery (Jerry mimics its interface). In this case you will need just to use the appropriate CSS selector:

// parse html
Jerry doc = jerry("<li class=\"item list1\"><a class=\"link\"></li>");

// get element by class name
Jerry li = doc.$(".item");
// or
Jerry li = doc.$(".list1");

Its simple as that :)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top