jQuery/PHP Replace Text with Title - php

Trying to replace the Text inside an <h1> with the text inside the <title> with jQuery.
$('.pagination').each(function(
$('.pagination h1').replace($("html head title").text(););
);
I don't really know how to do this, I sorta hacked it together.
EDIT: Or, does anyone know how to do this with PHP?

You can get the title of the page using document.title. Instead of using .each you can just target all h1 tags.
$('.pagination h1').text(document.title);

In JavaScript:
$('h1').text($("title").text());
Replaces every h1 text in the document with the text inside the title tag.

$('h1').html( $('title').text() );
should do it

Here you go :
title=document.title;
$("h1").html(title);

Related

looking for the way to extract the value of a data-url property from a Li tag in html using "simple_html_dom.php" for scraping

I have a website with this li:
<li id="video1" class="streamList Playclick rippler rippler-inverse" data-url="http://54.39.16.47:25461/live/674475857/674475857/461.m3u8">
I need to extract the data-url value of it, am using simple_html_dom.php to scrape into the page.
have someone work do it with simple_html_dom.php? will be able to help me with an example of how to extract it?
Are you using this SimpleHtmlDom?
If yes, try it like in the examples (untested by me)
$html->find('li[id=video1]')->getAttribute('data-url')

How to replace text inside a PHP Document?

I am making a wordpress plugin, you can edit a page's title with it.
The title will be an H1 Tag with the ID of featuredTitle.
<h1 id="featuredTitle">This text will be replaced!</h1>
Now I need an input that opens the file "myPage.php" and replaces the text.
I am new to PHP so help would be highly appreciated.

Is that possible to remove <a> in a <img> in php or jquery without remove the <a> directly in php?

I want to remove the <a> tag that is wrapped around the <img> tag. No link, only the image show up, no <a> html tag at all. But, without remove the <a>directly in php
I tried using css a{display:none;}, but that will remove everything. Do you think is that possible to do what I ask in PHP?
See the code below.
<img src="" />
php is a server side language. Unless you are planning to pass your entire HTML code to PHP, it most likely will not achieve what you are trying to do.
On the other hand, there are several ways which you can do it in jquery. One way to do it is to call unwrap() on the img element.
$("img").unwrap();
This will remove the parent a element.
You should use jquery.unwrap
<script>
$(document).ready(function(){
$("img").each(function(){
var parent = $(this).parent();
if(parent.is("a")){ //Remove only if the parent is "a" tag
$(this).unwrap();
}
});
});
</script>
You can chain contents() into unwrap():
contents() will return all the children of , including nodes, and unwrap() can be applied to nodes.
Use : $("a").contents().unwrap();

Adding anchor tag to javascript URL

I have a PHP system and basically I use a popup lay to do some processing, ie upload an image. No problems here and then on completing the insert and upload I go to a page which will call the underlying page and refresh it:
$callpage="jobsheet_build.php?id=".$_GET['id'];
echo("<script language=\"javascript\">");
echo("top.location.href = \" ").$callpage.("\";");
echo("</script>");
OK this works fine, but in the ideal world I would like to put a reference to #images in the $callpage so I end up with
$callpage="jobsheet_build.php?id=".$_GET['id']."#images";
but the javascript just hangs no matter what I do.
Any ideas would be very greatly appreciated!
#Jim Have you tried to set the anchor tag like this echo("top.location.href = \" ").$callpage.("#images\";"); instead of set the anchor tag inside the variable ?

Wordpress - I want to add a <div></div> with a Plugin

I'm trying to learn wordpress and php.
Basically, I want the
function draw_ad() {
echo "IMAGE CODE INSIDE A DIV";
// echoing an image inside a div -- StackOverflow does not allow me to post img tags : )
}
add_action('the_content', 'display_ad');
===
Basically, I want to add a picture and be able to manipulate the "left" and "top" css options... but with a plugin. So it will be like a strange picture that covers whatever the area on the screen that I want it to cover :P.
Yes, it is kind of sloppy, but that's what I was asked to do : P.
The add_action('the_content', 'display_ad') kind of does it, but it removes the whole content.
Is there a better way to do this?
Is there a way to tell the wordpress PLUGIN to add this , say, before the theme's header, and not content? (As in, be able to put this thing wherever you want to in the html body tags?
Thank you, guys!
From theme developing I am sure you can add code to the header and at the end of the body tag. (wp-header, wp-footer)
The best thing is to insert the picture tag at the end of the body and style it with position:fixed;. You don't need a div around the img tag.

Categories