Why does not JQuery apply?

0

On a page (index.php) I have a div ('#body'), inside this body I post content through ajax.

My problem is that I have when I charge options.php inside #body, jquery does not work, but if in the browser I directly charge options.php jquery if it works for me.

The jquery library I tried to put it in index.php and options.php, but even so it does not work jquery, does anyone give me the answer?

The following code is what contains "opciones.php", and as I say, if I show it inside #body it does not work jquery.

<!DOCTYPE html>
<html>
<head>
	<title></title>
<style type="text/css">
	#opciones{
		width: 300px;
		height: 100px;
		background: #d1d1d1;
	}
	#editar{
		width: 300px;
		height: 120px;
		background: pink;
	}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#editar").hide();
	});

	function editar_opciones(){
		$("#editar").show();
		$("#opciones").hide();
	}

	function actualizar_opciones(){
		$("#editar").hide();
		$("#opciones").show();
	}

</script>
</head>
<body>
	<div id="opciones">
		Nombre: Vemos opciones<br>
		<button onclick="editar_opciones()">Editar</button>
	</div>
	<div id="editar">
		Nombre: Editamos opciones
		<button onclick="actualizar_opciones()">Ver</button>
	</div>
</body>
</html>
    
asked by Fabián Moreno 15.04.2018 в 18:49
source

1 answer

0

try to use

$( "#cuerpo" ).load( "opciones.php" );

If scripts come in the answer will be executed.

link

    
answered by 15.04.2018 в 19:03