I am trying to add an attribute autoplayin an iframe. However, this attribute is only markup, it does not matter:
<iframe src="..." autoplay></iframe
In Nokogiri, add the attribute as follows:
iframe = Nokogiri::HTML(iframe).at_xpath('//iframe')
iframe["autoplay"] = ""
puts iframe.to_s
---------- output ----------
"<iframe src="..." autoplay=""></iframe>"
Does Nokogiri have such a way to do this, or do I need to delete /=""/using the regex at the end?
thank
source
share