Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return DOM manipulated into a var ? #188

Open
devgiu opened this issue Dec 20, 2016 · 1 comment
Open

Return DOM manipulated into a var ? #188

devgiu opened this issue Dec 20, 2016 · 1 comment

Comments

@devgiu
Copy link

devgiu commented Dec 20, 2016

Hi, I'm trying to do a simple thing, but I can't figure out how to do.

I have the HTML code will be outputed to browser, on a var, $html.
For testing, I'm just trying one thing. With JQuery, I do this to move a DOM element:
$j('#someid').parents('.form-group').after($j('#anotherid').parents('.form-group'))

I'm trying the same but server-side, I think is something like this:

$qp = html5qp($html);
$qp->find('#totalDocumento')->parents('.form-group')->after($qp->find('#contador')->parents('.form-group'));

But I don't know how to "save" this DOM manipulation again to $html variable. Maybe I'm doing in wrong way, but looking into samples and documentation I don't have it too much clear.

@nick-andren
Copy link

You are very close. This should work:

$qp = html5qp($html);
$qp->find('#totalDocumento')->parents('.form-group')->after($qp->find('#contador')->parents('.form-group'));
$html = $qp->html();

Here, $html will now contain the HTML code as a string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants