douqin1932 2014-08-26 16:34
浏览 97
已采纳

获取段落的内容

I want something like this

<p id="potato">Here's some text</p>

<?php
SomeSortOfCodeToGetTheContentOfParagraph(#potato)
$value = TheOutPutOfTheCodeAbove
?>

So basically I want a code that gets the content of the paragraph with ID potato and makes $value equal to that

I read something about DOM but I don't really understand that

It doesn't have to be a PHP code, as long as $value is PHP and can be defined that way

  • 写回答

3条回答 默认 最新

  • dougangxin5695 2014-08-26 16:39
    关注

    PHP is a server side language, that means all the code you write evaluates before generating the DOM, you can't manipulate DOM like you want after it has been rendered. To do that you need to use javascript which is executed on the DOM, with php you can't basically do what you're trying to achieve, what you can do is retrieve the text with JS and pass it to PHP with GET or POST methods.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 python怎么在已有视频文件后添加新帧
  • ¥20 虚幻UE引擎如何让多个同一个蓝图的NPC执行一样的动画,
  • ¥15 fluent里模拟降膜反应的UDF编写
  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题
  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵