3

i need to get 'svg' element inside 'object'. Normally we can use $("object").find('svg') but the problem is the presence of #document.

I also tryed maybe every combination of $( "#id" ).contents().find('svg') or again $($("object").get(0)).find('svg') ,

and believe me, many more....

Thx in advice for help.

html code:

<object data="./images/image.svg" type="image/svg+xml" class="class-svg" id="id">
 </object>

Not on topic but not exactly off topic... You could simplify your code to make it more manageable and easier to read.

<? foreach ($row_specifics as $title => $value): ?>
    <label class="control-label col-lg-2"><?= $title ?></label>
        <div class="col-lg-1" style="padding-right: 5px; padding-left: 0px;">
            <div class="make-switch switch-small" data-on="success" data-off="danger">
                <input id="specs_value" name="<?= $title ?>" type="checkbox" value="<?= $value?>"<?= $value=='on' ? 'checked' : ''?>/>
           </div>
        </div>
<? endforeach ?>

This will remove the need for the if statement and the block of repeated code.

4

1 回答 1

0

SVG 文档对象模型 (DOM) 与 HTML 文档对象模型 (DOM) 有很大不同。因此,它与 HTML DOM 的工作方式不同。

可以使用 jquery-svg 插件来实现。

https://github.com/mberneti/jquery-svg/

于 2018-02-01T10:13:43.583 回答