[英]I'm am trying to change a css property using $_GET getting wrong result
First of all this is a wordpress page so [insert_php] is a replacement for <?php
. 首先,这是一个wordpress页面,因此[insert_php]替代了
<?php
。
The url of the page is as follows http://********.com/?page_id=98#highlights?sel=q1s
该页面的网址如下
http://********.com/?page_id=98#highlights?sel=q1s
the code on the page is as follows 页面上的代码如下
<div id="Question1" style="background-color:[insert_php] if ($_GET['sel'] == "q1s") { echo "black"; } else { echo "white"; }[/insert_php];">
this is my current code and it still showing no results, I checked the actual value I'm getting for background-color and for some reason am getting the result "white". 这是我当前的代码,它仍然没有显示任何结果,我检查了我为background-color获得的实际值,并且由于某种原因得到了结果“ white”。
This is because the second parameter sel
passed in the URL should be directly appended to the first argument declared with the ampersand ( &
) identifier. 这是因为URL中传递的第二个参数
sel
应该直接附加到用&
标识符声明的第一个参数后面。
The use of the fragment identifier ( #
) in the middle of your arguments is misleading as he can also be used to declare arguments to the URL. 在参数中间使用片段标识符(
#
)具有误导性,因为他也可以用于声明URL的参数。 If the hash mark is meant to identify an anchor, it is better to place it at the end for avoiding errors and better readability : 如果哈希标记用于标识锚点,则最好将其放在末尾,以避免错误和更好的可读性:
http://you-url.com/?page_id=98&sel=q1s#highlights
Try something 试试看
<div id="Question1" style="background-color:[insert_php] if ($_GET['sel'] == "q1s") { echo "black"; } else { echo "white"; }[/insert_php];">
[insert_php] echo $_GET['sel'];[/insert_php]
</div>
and see what is in the $_GET 并查看$ _GET中的内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.