Skip to content
Thomas Weinert edited this page Jul 31, 2014 · 1 revision

FluentDOM\Query::removeAttr()

FluentDOM\Query removeAttr(string|array $attribute);

Remove an attribute from each of the matched elements. If $name is NULL or *, all attributes will be deleted.

Usage

$html = <<<HTML
<html>
  <head>
    <title>Examples: FluentDOM\Query::removeAttr()</title>
  </head>
  <body>
    <div>
      <p index="0">Hello</p>
      <p index="1">cruel</p>
      <p index="2">World</p>
    </div>
  </body>
</html>
HTML;

echo FluentDOM($html)
  ->find('//p')
  ->removeAttr('index');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::removeAttr()</title>
  </head>
  <body>
    <div>
      <p>Hello</p>
      <p>cruel</p>
      <p>World</p>
    </div>
  </body>
</html>
Clone this wiki locally